Polar projection
targetX = sourceX + dist * cos(angle)
targetY = sourceY + dist * sin(angle)
You basically compute the target coordinates as if you were travelling from a source location into a given direction at a given distance.
So if you want a group of 3 rows and 4 columns for example, set the center location, the angle ang of the formation and the distance dist between each unit, you can go 3./2*dist towards ang, 4./2*dist towards ang+90° to reach a corner. From there progressively (in a 2d loop) return (reversed ang) in steps of dist to get the individual spots to place units on.
Walking consistenly together however can be a problem. You either have to sync and redirect the targets since you never know if some units get stuck somewhere or maybe better issue the commands as unit group (Unit Group - Issue Order...). That works for unit groups of max 12 units and is like the formation setting next to the minimap ingame. I do not know what the distance between the units it uses there depends on.
edit: When using that group formation feature, the units may also get their spots swapped/reassigned. They do not strictly walk in the exact formation the whole time, only try to shape up at the target location.