First of all, while most modern operating systems prevent writing to code by default, all common systems provide a way of overriding this behaviour. This is necessary if you want to use a language or environment that has a JIT compiler (e.g. Java, .Net, node.js, etc.). So you don't need a specific os for this.
Secondly, many existing languages provide facilities for this, although the facilities vary in ease of use radically. For example, both the .net framework and javaJava virtual machines support libraries that effectively allow you to produce new classes that contain code generated using the assembly language representation of their virtual machine Instruction sets. Other languages, e.g. Javascript and Ruby provide a mechanism usually called "eval" that will take a string of text in the language itself and execute it. This is commonly thought of as a facility primarily of interpreted languages, but many languages originally intended to be interpreted can now be compiled to native code, so the distinction is less than you might think.
Lisp (and derivatives like Scheme and Clojure) takes a third approach: code has the same structure as data in these languages, and can be directly manipulated. This similarity of structure is called HomeiconicityHomoiconicity and is a very useful property of languages for programs that manipulate code directly. Again, many such languages are compiled to native code prior to execution.