Yeah you can code in machine code (most CPU makers provide detailed manuals for their instruction set). But it's more common to program in an assembly language, which more human readable and typically maps 1:1 to machine code. But there is nothing stopping you from coding in machine code directly. I had a professor that claimed this wasn't uncommon in the 70s.
There are many assemblers for x86/AMD64, here is one example often used for learning (free/multiplatform) called FASM:
You can even write your own if you want a challenge.