It is hard to give advice for your child because each child is different and each parent has a different approach, but I thought it might be helpful if I outlined my experience as my DD1 reacted in a very similar way at an activity class.

I find my DD can get overwhelmed by groups of children very easily and she also gets very overwhelemed by too many instructions + being told what to do generally!! Part 2 year old and part her personality of liking to discover in her own time rather than be directed. She is very much a watch and observe type of child who will do things on her own when ready. (DD2 is the complete opposite and will launch herself into things, trying it out to learn)

DD1 would withdraw in this class and refuse to participate and we found that if we tried to push her she dug her heels in. DH was taking her to the class and reporting back to me and I was concerned about it, but when I went along instead it was very clear that she was really overwhelmed and trying to protect herself in the only way she knew. DD appeared to enjoy the beginning of the class but when things got more hectic or the instructions from the teacher got too complicated or too demanding she pulled back, refused to participate and began to sook a bit. She was clearly overstimulated and needing to calm herself.

To me it sounds very similar with your DS. His behaviour sounds like he is physically trying to find a way to deal with the overstimultion by folding himself up physically. Going off to do his own thing is a safety mechanism for him to manage all the incredible things going on in his head.

I think, give him the space he needs to manage his feelings and let him know he is safe to do this. It is a wonderful lesson for him to learn to manage such intensity and I believe pushing him would not be helpful. It is also how I went with my DD in the end. I would just let her play in the corner if she wanted and I would continue either to sit with her if she wanted it or I would continue to play, dance, be involved in the class if she didn't (setting an example). Unfortunately the teacher pushed her and tried to get me to push her so I decided the class was not for us.

Interestingly, we have tried again with DD now she is 3 and it was a shambles once again (children in the group crying, mothers dismissed and a general feeling of illease... and this was the orientation class supposedly!) A discussion with the teacher since has confirmed my suspicions, we are on different wavelenghts with what we expect from toddlers so I have said goodbye to that organisation!!!

I read a great book about how the minds of toddlers work that explains their ways of dealing with the world around them, "Toddler Sense" It is a good read to get your head into theirs.

ETA: I just googled the book - by Anne Richardson and found a web page devoted to it. It may be worth a look as the book is really exceptional when it comes to explaining a toddler's world.