I use Docker (Podman actually, but both works) as the container can be amd64 with Rosetta and Podman (there is a solution for Docker too).
Then I build an image like that, and I run inside the container (I override the default keyboard layout with mine, so that I don't have to create a user).
When you run it, mount a volume from your machine as '/output' and copy the bin or do a podman/docker copy
.
FROM docker.io/qmkfm/base_container:latest
RUN pip install qmk && \
qmk setup -y -H /qmk_firmware
WORKDIR /qmk_firmware
COPY keymap/keymap.c /qmk_firmware/keyboards/novelkeys/nk65/keymaps/default/keymap.c
COPY config/qmk/qmk.ini /root/.config/qmk/qmk.ini
# Make Bash as the default command
CMD ["/bin/bash"]