Yes, it is possible, although it's not entirely easy. Most app footage is actually recorded from the simulator, rather than the device itself.
However, I did it for
Alien Swing by using glReadPixels to store frames saving it to the documents, transferring the data to the Mac and then using OpenCV to convert the stills into video.
Although, actually it's a bit more complicated than that because glReadPixels is slow, and you rack up a lot of data quite quickly so if you're at all tight on memory you'll need to write to disk frequently which slows things down making it hard to play. Now, with Alien Swing I'm fortunate in that most of the screen doesn't change, so I could store which parts were changing and only capture these parts keeping the storage requirements down to sensible levels and mean I could keep running at 60fps with only the occasional slowdowns when it has to write out to disk while recording at 20 fps.
You can see some resulting footage
here (cut together with iMovie) and
here - obviously this method doesn't record sound so I had to patch that in afterwards, although I suspect it could be automated with a little more work.
I posted about this
on my blog as well.
Now, if you wanted to do it on the device, you'd have to do the coding on the device and I don't know of any good libraries to do that so you might have to write your own. Otherwise I suppose you could upload data to a server and have the server process and pass it on to YouTube - although that would add server costs.