Absolutely, but the question is why?
All program code eventually becomes binary machine code. Writing in binary to begin with would just be an exercise in masochism.
Here's how programming generally works:
- The programmer writes code in a human-readable language, such as C++, Python, or Java, just to name a few.
- A computer program called a compiler takes this human-readable language, parses it, and turns it into machine code. This machine code is specific to the computer architecture executing it. Alternatively, instead of machine code, the code can be compiled into assembly. Assembly is, more or less, human readable machine code (it's slightly more complex than that).
- This optional assembly step is then converted into binary machine code.
The program's machine code is already in binary, and is generally known as a "binary executable." This binary code is highly specific to the CPU running it. Technically you can skip steps 1-3 and write the binary code directly, but this isn't very useful to do and just makes things harder for you as the programmer. Sometimes patches are done this way if you don't have the original source code and you want to "hack" an existing binary program, but you generally don't just go directly to binary.
Another issue is, since the closer you get to binary, the more machine-specific your program, it doesn't make as much sense to write a program (in your case, a virus) in binary, as it wouldn't be able to infect "every computer-based system" in the world. How many architectures a program can run on is known as portability, and in general the higher level language you use, the more portable your program.
For example, Java is meant to be very highly portable, however the way it accomplishes this is a bit of a cheat: It creates "virtual machines" that are implemented on the target hardware. This way, your java program can run on any machine that has a java virtual machine program on it.
Unfortunately, these virtual machines also tend to be relatively good security layers, in that they create a sort of "sandbox" for the programs they run. It's not impossible to escape this sandbox, and indeed a lot of security research goes into checking virtual machines for these types of escape exploits, but in general, the idea of writing a virus that can infect any machine connected to the internet is essentially reserved for fantasy. In fact, a large amount of time and money is spent just making programs that can run relatively painlessly across several architectures or operating systems. Life would be a lot easier if it were possible to simply write a program that can magically run anywhere.
Python, on the other hand, is "interpreted." This means that Python code itself [usually] isn't compiled into machine code, and instead is run through a program called an interpreter. This interpreter, as the name suggests, interprets the instructions in the Python program for the architecture running it. Interpreted languages tend to be slower due to this intermediate translation step, and, just like with Java, you have the problem of needing a new interpreter for each architecture you want to run your python script on.
This doesn't rule out scenarios involving artificial intelligence, however, as it is certainly conceivable to write an AI that is able to study all of the computer architectures it encounters and determine how best to port itself to the new architecture. In this case, the AI would almost certainly write binary code (or some kind of very low level intermediate language of its own design) in order to port itself to the new architecture.
So it makes more sense for your villain not to write his/her program in binary code, but instead to write a program that itself writes code, specifically binary code for any architecture it encounters.
Such a program would need to be very complex, as it would have to first find uninfected computers on the internet, probe them for vulnerabilities, and learn the architecture they're running in order to reformat itself to run on their architecture. Based on the definitions just given, it's clear such a program would, by necessity, be a learning algorithm, and such a program would also grow in size as it finds and infects new architectures and operating systems.