MIDI would be overkill. A pitch-duration table along with the code to vibrate the speaker at the right frequency for the right amount of time would be far simpler.
It played over the piezoelectric motherboard speaker, the one that usually emits only a beep, and is intended to play a given frequency for a given duration. It's possible to use pulse width modulation to make mediocre digitized sound come out, but it is quite complex and would use a lot of BIOS space. A simple sequence of notes, however, is compact and easy.