Events
Unit A is within 800 range of Unit B
Actions
Move Unit A to position of Unit B offeset by x,y
Display text "lol you can't separate those doods, guys"
something like that
If you want an effect, the easiest way would be to give Unit A a blink ability and have it cast it at the position of B (then removing the ability immediately after), though that could be a potential point of abuse.
The above should work fine though, if you don't mind the fact there isn't any SFX, just a message telling the player not to do that.
You could also do it with an aura, if a unit leaves the range of the aura, he's teleported back to the unit.
...The messiest way would be to create a rather large region and place it at the position of your hero, make a trigger move the region to the position of Unit B every 0.5-1 seconds, if Unit A leaves that region, teleport him back to the center of the region. That's just an idea though, now that I think of it, something like that wouldn't probably work.