Basically, the thing you want to do is similar to what a Xel'Naga tower does, except a little more. Good thing this is achievable.
Make a new Ability, and set its Type to Interact. Then set both the Ability - Auto Cast Range and Stats - Range to a value, and check the flags 'Auto Cast', 'Share Control', 'Share Vision' (optional) and 'Same Cliff Level' (optional) at the Stats - Flags field. Last thing to do is look at the Target Filters of the ability.
Then add it to your unit, and it should share the building. Do note that even though you share the building, you can't buy anything which costs minerals / gas / whatever, since it gives the error 'You can't use someone elses minerals blabla'. =(
If you need any help with it, you could also take a look at the Xel'Naga ability, named 'Tower Capture'.