Warning
Create a Time Machine backup before major updates, disk operations, or security changes on macOS.
What you will achieve
Keep a USB installer handy before the Mac will not boot — official Apple method.
1) Download installer from App Store
Get the exact macOS version your hardware supports.
2) Prepare USB drive
Use Disk Utility to erase USB as Mac OS Extended (Journaled) with GUID partition map.
3) Create bootable installer
sudo /Applications/Install\ macOS\ Sonoma.app/Contents/Resources/createinstallmedia --volume /Volumes/MyUSB