You can use the physics.set_mask_group() et.al to manipulate your groups/masks.
You can also enable/disable collision objects.
I think it’s probably a good idea for you to group your objects together (e.g. in a “squad”) once a collision between units has been detected, so that you can make then choose some new target position nearby (so they don’t overlap too much)
E.g. there is DefArmy that does something like this.