MacOS Cannot format to APFS
I do not know if you read my answer to the question you refer to? The command diskutil apfs createcontainer disk0 should have failed. You are suppose to create the container inside a partition (or two partitions where each partition is on a different drive). You specified disk0 which usually is the primary internal drive on a Mac. Maybe you were able to create the container, but being unable to create a volume would not be an unexpected result. 

Below are the commands from my other answer.

diskutil eraseDisk JHFS+ dummy GPT disk0
diskutil apfs createContainer disk0s2
Container=$(diskutil info disk0s2 | grep Container)
diskutil apfs addVolume "${Container##* }" APFS myVolume


The first command creates the partitions. The second command create a APFS container in the second partition. The third and fourth commands creates an APFS volume in the APFS container.