The audio output by the speakers is not exactly the same as the audio signal coming from the computer, and it also is delayed. It's basically just inverting speaker sounds, that when played along with the microphone input that's picking up speaker sounds, cancels out any sounds coming from the speakers being picked up by the microphone. The only way to do it would be to route all of the sounds that come from the speakers into a DAW, while also routing the microphone input, and then inverting the speaker sounds, playing both at once and then using what it plays as the real microphone output. However it might not work that well in practice.
It's theoretically possible using software (most likely a DAW of sorts).