Fetching ubuntu cloud image from https://cloud-images.ubuntu.com/.
Then using the QEMU backend of Packer to customize the image and build a new image out of it:
QEMU is capable of using the MacOS hypervisor-framework to run vm-s with the MacOS-native hypervisor:
The build mounts the cloud image of ubuntu, as a system disk, then an initial cloud-init config is run from a cdrom mount to set up a provisioning user so packer can log into the instance and do it's thing: