I own an iPhone 3GS and use it as personal hotspot for my MacBook Pro via USB.
The iPhone is running iOS 5.1.1, and the MacBook is running a Mountain Lion preview. However the question is not about Mountain Lion, nor is specific to Mountain Lion, so please bear with me.
The iPhone was in the locked mode and connected to the MacBook via USB when I pressed the lock button. However, instead of the usual lock screen and slide button, the iPhone showed a fullscreen ad:
(Ironically, it advertises a game called “Worms: Reloaded”.)
I was somewhat terrified by this so I didn't tap the image at all, and instead held the poweroff button. On choosing “Cancel” on poweroff confirmation screen, I was able to get back to my lock screen.
I don't know what would happen if I tapped the image, neither do I know if this was just an image or an executable. It's kind of funny that the ad says to push OK (YES) button, but there is no such button on the screen. I decided I don't trust this interface because of strange arrow positioning in the top left button so I didn't tap Cancel.
My phone is not jailbroken.
By the way, there has been a similar question without a screenshot but I'm not sure it is exactly the same thing.
My only guess now is that I have MMS enabled, and maybe there is a kind of MMS messages that show up on the screen without being saved (like flash SMS), and maybe my carrier decided to spam me. I'm also downloading a malware scan software for OS X.