Is there a way to check the serial number of the machine without logging in?
One way is via the box it came in; another is the "paperwork" associated with it.
Some models (like the Mac Mini) have the serial number on the case.
As for the iMac, unless you have the box or the original sales reciept, as far as I know, you're out of luck.
You used to be able to click to see the version, whether Network Accounts were available, the serial, etc at the log in window, now not so much...
"Is there a way to check the serial number of the machine without logging in?"
Yes. For iMacs look under the leg. lt will test your eyesight though! Turn a MacMini over and it's underneath. Same for MacBooks.
Retrieving data ...