How to erase data from Macintosh HD - Data - Data?
Apple shows how to completely erase the disk here.

https://support.apple.com/en-us/HT208496

You have to boot to internet recovery since the system can’t erase itself while running, but you can sometimes script a reboot that then performs the erase...

https://github.com/grahampugh/erase-install

Or connect to a different Mac over target disk mode (or even a PC could format the disk and you would need internet recovery or external installer to reinstall the OS).