Prerequisites: Virtualbox 6.1+ with extension pack installed.
1. Boot macos from virtualbox
Follow the steps in this tutorial to do so.
2. Configure USB access within the macos guest
2.1. In your VM settings, set usb version to 2 or 3 depending on your configuration.
2.2. Add yourself to the vboxusers group
In your host terminal, run:
sudo usermod -aG vboxusers YOUR_USERNAME
Close your host session and log back in for the changes to take effect.
2.3. Insert linux guest additions disk into the guest machine, open it and run
VBoxDarwinAdditions.pkg to install guest additions.
2.4. Your USB flash drive should be listed in USB devices for you VM now, add it.
3. Actually make you USB flash drive macos bootable
3.1. Format you USB flash drive to
Mac OS Extended.
3.2. Download the macos installer and disk creator for the version you want to install, follow the disk creator step.
3.3. Unmount USB stick from the guest, unmount from the host and voilà, you have a macos bootable USH flask drive.
The installer is damaged, and can't be used to install macOS.