This seemed to become a bigger problem with the introduction of macOS High Sierra (10.13) and the APFS file system. Essentially the problem is, in Disk Utility, you can’t erase a boot drive, it will just return an error that it can’t unmount the disk.

The solution lies in a single Terminal command. Assuming you are trying to reformat the internal hard drive (always called “disk0” in this command):

diskutil unmountdisk /dev/disk0

After that, you should head back to Disk Utility and it will allow you to reformat that drive now.