When attending a class or presentation, audience members should be courteous to the speaker and refrain from speaking. Chatting during a presentation is also rude to the other attendees who want to hear what the speaker has to say.
If you are the speaker and encounter chatty audience members, simply stop speaking and wait for the chatter to stop.
I practice this skill from day one in my college ballroom dance classes. The students quickly learn only one person should be speaking at a time. When I become quiet, they actually police themselves. I frequently hear, “Shh, she’s trying to speak” without ever having to ask them to be quiet.
A preschool teacher told me she whispered when her students became chatty. Walking around the room, she would whisper, “If you can hear me, touch your nose”. She said it works like a charm because none of the children want to miss out on a secret, so they stop talking and listen attentively.