Updating Through Terminal in macOS Recovery?

Weird question for y’all. Sometimes out of the box, Macs are preloaded with an older version of macOS, like Sonoma and not Sequoia. Normal setup would update these Macs to the latest version of Sonoma, leaving it up to the user to update to Sequoia in System Settings.

Due to my job, it would be super convenient to be able to update to the latest macOS before setup, and I’d like to know if this method makes sense:

Booting a new Mac into macOS Recovery, launching Terminal, and entering

sudo softwareupdate -i [update name] -R

The idea is to update it within macOS Recovery and then begin setup. Would this work?