I've experienced the following on both an STM32F4, and in my recent experiments with a Pi Pico.
(My goal, which isn't particularly relevant to the question is to create a -12V to +12V square wave using an H-bridge. To drive it I use the 2 microcontroller pins)
When one of my GPIO pins is high, the other is low. (They will feed into the INA1 and INA2 of the H-bridge)
The outputs of the microcontroller are the default Push-Pull. My understanding is that when LOW, it should be switched to GND.
Here is the output when I connect the scope to my two alternating GPIO pins 
And here is the output when connecting to 1 of my GPIO pins and actual GND 
So why all the extra noise when using a GPIO pin as a ground, and can I do anything about it?
UPDATE
In addition to the comment replies I have made, the issue is power supply related. In both examples the microcontroller (a raspberry pi pico in this case) was being powered through USB. When I removed USB power and connected a buck convertor, the output across the 2 GPIO pins becomes a nice noise-free square wave. While I can't explain the exactly why this works (I would probably need to understand the pi pico build-in power suppy), I am happy that my design will work.