It depends. Are you attempting to erase the storage device that contains the MacOS operating system installation, or simply an external (i.e. USB) storage device? If the former, you'll need to enter recovery mode (by holding Command+R during the boot sequence) and use Disk Utility to erase the storage device. Whilst in recovery mode, you can also reinstall MacOS. Note that you'll lose all of your files and settings, so if you have a Time Machine backup, it may be worthwhile trying to restore the most recent working backup beforehand. If the latter, you can use the Terminal application to identify, unmount, and erase the storage device as follows:
sudo diskutil list
sudo diskutil unmountDisk /dev/diskX
sudo dd if=/dev/zero of=/dev/diskX bs=10m
sync
It will be quicker to simply erase the partition table on the storage device, but if you want to be thorough, this is the best approach. Once this process has completed, you should then be able to use Disk Utility to create a new partition table by formatting the storage device. To reiterate, you will lose all of your files and settings and they will be irrecoverable, so please ensure you have backed up your important data.
I hope the above helps you out.