You probably need to determine the relative position to the center of the unit group of each unit within the unit group and then order each unit to move to a point depedning on its relative position in the unit group.
For partially blocked terrain or a non linear path, the units will still not move perfectly in formation.
For the best result you probably have to make periodic checks and reorder them to new locations periodicaly, which is not that easy and very inefficient.