if your input signal were bipolar, i would have recommended the following: use an analog 4-quadrant multiplier. signal on the X input, switch to choose between a positive or negative DC voltage on the Y input. with positive on the Y input, output is noninverted, with negative on the Y input, output is inverted. advantage here is you can replace the switch with another square wave generator, and get it to switch automatically.
an XOR is the digital equivalent of the same function. since your input is a TTL logic level, use an XOR gate.