I think the answer is most likely no, not in the most notable examples of AI programs (such as Machine Learning). There is a set of AI techniques which involve automatic programming, but in that scenario, we have a computer program which automatically codes another program (we can call it "target program"). But the target program is not the program which perfoms the coding; so technically speaking, no, it does not write its own code. This is an important difference; the programmer still has the task to write the code-generator.
If you are interested in automated coding, though, the most notable example is Genetic Programming, a technique which uses an evolutionary algorithm to breed computer programs. As you can see, we have an AI which produces as a result a computer program (which may be or not an AI program); it is not interacting with its own code.
As a final remark, note that automatic coding is a pretty vague term and not all techniques are AI-related (for instance, back then, the first compilers were seen as a form of automatic programming). The most relevant techinque to your question is probably Program Synthesis.