The VT100 can command the keyboard to emit beeps and key click sounds. But it's not a simple square wave. The sound circuit is described in the Technical Manual.
So essentially, the sound is generated from an RC circuit. I'm not an electrical engineer, but I can read up on the equations. Simulating the circuit may seem overdoing it, but it's a tiny overhead compared to generating the video anyway. I added a separate window to display the sound as on an oscilloscope. It's disabled, but it's still there in the code. Here's the beep. The capacitor quickly discharges through the speaker, and slowly charges back. The VT100 ensures the cycle repeats, generating a sound at around 780 Hz.