https://support.apple.com/en-us/111336
If you have an external storage device, such as a USB or Thunderbolt drive, you can install macOS on that device, then use it as a Mac startup disk…
* You can buy a ~$600 M4 Mac Mini with 256GB and add a 4TB External Thunderbolt 3/4/5 SSD and install MacOS on that drive.
You get a 4TB M4 Mac Mini for under ~1000. The internal 256GB SSD is still bootable in case of need.