I wish I could!
It really is the depth that makes it a non-starter -
Brother HL-2040 =
36.2 cm!!!
Why do the Brothers always seem to have such large footprints!

(although the Kodak AIO 5100 is even deeper than that)
On the laser units, Brother lays the path flat, where HP made it vertical. It does make better sense space wise, but causes other problems with paper handling. Particularly with envelopes, index cards, etc.
I have an idea for the space issues, but don't know the specifics of the room...
Have you considered mounting a shelf to the desk in the fashion of a book case, or even on the wall above the computer? Beside it...?
I've always found getting it above everything else solves many space issues, if such a location is possible. You just have to get up to reach it. In the case of the HL-2040, it could be done. Not too big or heavy. And, when you print, the output lays on the top of the printer, so it won't fall in your face.
Can't say that for the HP's I've used this way when I had to use the alternative paper path (envelopes).
A shame the cost of refills makes inkjets so uneconomical, and the HP laser printers have such unreliable Mac drivers/support.
Don't forget the HP laser supplies expire.

They're more expensive as well.
Not even too fussed over whether it's b&w or colour, inkjet or laser now, tbh - I just need something inexpensive (which also doesn't cost a bomb in refills), Mac friendly, and compact (at least depth).
For low cost, B&W is really the only laser possible. Otherwise, you'll wind up around $300USD(165GBP). Not bad for color laser, but not wonderful when on a tight budget.
I'm tempted to bite the bullet with an HP and hope that their Mac drivers do the job. The HP LaserJet P1005 is only
£59.22 on Amazon, and it says it's compatible with 10.4 and 10.5. While their drivers have been temperamental, I know the print quality is generally very good.
Decisions.......
Decisions are always the hard part.
I liked and used HP printers for years. But some of the issues I've had recently, have changed my opinion of them being the best choice these days. Not considering the Mac driver issue, it seriously pissed me off when I discovered the toner cartridges would expire, used or not! To me, that decision was wrong by HP. Follow it up with the bloated, crap software, I began looking elsewhere.