For example:
https://online-sms.org
https://quackr.io/temporary-numbers
(there are hundreds of those and they work, I've just tested it)
Then there are professional services such as Twilio.
Due to the abundance of those websites I assume it must be fairly straightforward to get such a virtual number yourself, but my best Google Fu didn't yield any good results.
Does anyone know how this works and would be able to shed some light on it?
You can get an old Wavecom cellular modem for few dollars on ebay, from a software point of view you open the serial port and send text AT commands to say "list messages" "send me message 1" "delete message 1"
In some countries you would need to consider the 2G switch off, a 4G modem is going to be a bit more expensive