Simple and efficient way to send a 5V square wave to an 8ohm 1W speaker
If you need to drive a square wave the usual trick (from the piezo days) is to use an H-bridge do double the applied voltage:

On 'forward' you have 5V applied
On 'reverse' you have -5V applied

… driving thus the speaker with a 10Vpp signal
You could use a bridge intended for small DC motors, the load is in fact similar.
Just remember to switch off the bridge when you are done otherwise you'll burn the speaker with a DC signal.