If you're saying WiFi is an option, then go for this. You need a WiFi capable Raspberry Pi board or a USB dongle. In addition to @goldilocks answer, there are also 4G HATs (e.g. from Waveshare) for the Raspberry Pi that allow for a compact integration and sometimes even have GPS included.
The answer is the same as it would be for "how can I connect my laptop to a 4G network", etc.
Using a 4G USB modem; these come in stick size form factors and start at ~$20 US.
Using a portable 4G wifi router.
By connecting via phone (or other 4G connected device) hotspot.
All three of these require a valid SIM, obviously.