Improvising in dance classes with other musicians can be wonderful! Here are a few things I’ve learned to make cool and effective:
Limit the number of pitched instruments. If you have a pianist, it can be difficult to coordinate harmonic progressions with a bass player, guitar, or additonal keyboard player.
Create a system to coordinate if you have more than one pitched instrument. For instance, decide on a harmonic progression or mode for each combination.
Play more simply than you would as a soloist, and leave lots of space.
Play quieter than you would as a soloist, especially if you’re a drummer/percussionist.
Inject new ideas/motifs/gestures from time to time - don’t just imitate what you hear.
Watch the dance. It’s tempting to get lost in the music, but it’s more important to watch what’s happening when you’re part of a group.
Listen to the dance teacher. It’s easy to get chatty between combinations with the musicians and miss important info. Also look and listen while playing, just in case.
Decide (or know based on context) who the ensemble leader is, and follow their lead. Collaborations tend to work best if there is a “benevolent dictator” who can make decisions.