This is hard to answer because, just like with artificial intelligence, once we have accomplished this it will be because we will have written a program that does it. And critics will say, "well, this machine isn't really programming itself! it just follows exactly the program you gave it!"
Well yes. Whatever we will ever accomplish with computers, we will do by giving it some program and it will execute it. If that's an argument against, then we can't accomplish anything. And yet, at some point, people thought a chess playing computer would be obviously intelligent. Now they can, and we know exactly how, and we don't think that's intelligent. Submarines still can't swim.
So -- consider a few examples.
Since decades, we have had parser generators. You give them a description of a language, it is processed and the result is code for a parser for that language. We know exactly how it's done, but isn't that a computer programming itself?
Second -- editors that tell you you've made a mistake (syntax error, non existing variable, etc). It doesn't program anything itself, but it can tell you that you did something wrong. It's very much on the surface only.
Languages in which you can just click and drag UI controls, and the code that will actually make them work is generated automatically.
JIT compilers. Software that can recognize hotspots in the currently running software and replace some of that by highly optimized compiled code, effectively optimizing itself while it runs. I think this is an example of what can seem to be a machine programming itself, until you know exactly how it happens, and then it turns out to be just doing what the programmer told it to, as always.
General game playing. This is an interesting field of research, in which researchers write programs that can read descriptions of the rules of games, that the programs then play against each other. So instead of a tic-tac-toe program or a chess program, these are programs that read the rules of tic-tac-toe or chess or some new game made up on the spot, and can then play them. The program isn't programming itself, but it does play chess without the rules of chess having been hardcoded. There was a time when this would clearly be considered the computer teaching itself something.
We've taken lots of small steps in the general direction.
But I can't think of any programs that rewrite themselves based on the results of earlier runs, or that can recognize obsolete or inefficient routines in their own code. I think that one day we will have that, and we'll consider it nothing special at all, as it'll be just some feature of the latest compiler...