Use the following command to check macOS version
softwareupdate --list-full-installers
For example
softwareupdate --fetch-full-installer --full-installer-version 11.7.11
Use the following command, change OS name and volume name based on your needs
sudo /Applications/Install\ macOS\ Ventura.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume