"Would just using an M.2 work? (Without using any hard drive or SSD)"
Question doesn't make sense - - - - an M.2 is an SSD - - lol
However, that aside, some boards can't boot from M.2, in which case it can only be used for extra storage capacity, so indeed you'd need to install an additional SATA HDD/SSD for the OS.