Shared Transformer Grouding
I have ability of providing the top of primary winding with a square
wave voltage alternating between 0 V and 9 V

If you put a signal onto a transformer primary that doesn't have an average DC level of zero, the primary current eventually becomes infinite. Obviously, long before that happens your signal source current limits and things stop working. Just regard the primary as being an inductor and that should be clear.
If you AC couple (via a capacitor) the signal to the transformer primary then the average signal on the primary is zero and you're now driving the transformer as it should be driven.
However, the waveform from the secondary also has an average value of zero and there's nothing you can do about that without using steering diodes and clamps to recover that signal to be roughly 0 to 9 volts x N.

would a shunt resistor help the situation?

No.