Converting a file to an .iso can mean a few different things depending on what you're working with.
mkdir ~/pkg_extract
xar -xf MyApp.pkg -C ~/pkg_extract
cd ~/pkg_extract
cat Payload | gunzip -dc | cpio -i
mkdir ~/iso_source
mv [extracted_files] ~/iso_source/
hdiutil makehybrid -o ~/MyApp.cdr ~/iso_source -iso -joliet
hdiutil convert ~/MyApp.cdr -format UDTO -o ~/MyApp.iso
mv ~/MyApp.iso.cdr ~/MyApp.iso
: Unmount the volume and convert the DMG to a CDR/ISO format: hdiutil detach /Volumes/Install\ macOS\ [Name] how to convert pkg to iso
hdiutil makehybrid -o ~/output.cdr ~/iso_source -iso -joliet
hdiutil convert ~/output.cdr -format UDTO -o ~/output.iso
mv ~/output.iso.cdr ~/output.iso