We had a very similar thing with Merlin when he first went to class. What worked for us was a combination of things:
- doing training before training class to reiterate focus
- at the training class venue, taking him for a jog around the block first
- in the training venue before class starts allowing him to say hello to the other dogs with the consent of their owners
- during class, working twice as hard as everyone else with really smelly treats to keep him busy. When required to sit quietly even that is a sit and 'watch me' and rewarding for duration of eye contact.
- repeated attendance with the same dogs present eventually calmed him down anyway
- practising in different environments with distractions
- just accepting that our beautifully behaved dog at home turned into someone we didn't recognise at class (different context with the ultimate distractions)

Hope that helps

he still has moments but when he focuses he's a star pupil!