Issues erasing APFS disk
To reinitialize the drive, you can enter the following. If this does not work, then you should consider that the drive, cable and/or controller may have failed.

Enter the following command.

sudo diskutil unmountdisk disk0


If disk0 does not currently have any partitions, then you will receive the following message, which can be ignored.

Unmount of disk0 failed: at least one volume could not be unmounted


Next, enter the following commands.

sudo gpt destroy disk0
sudo gpt create -f disk0
sudo diskutil partitiondisk disk0 1 gpt apfs "Macintosh HD" R