A melee attack you can escape from is when you are grabbed by an enemy, and you are prompted to waggle the left stick to escape. This will likely come through regular play.
It is quite random that you get into the animation. Sometimes the enemies will just punch you, or continue you to shoot you, but there are lots of enemies to fight in close quarters that can grab you.
NOTE: This does not include the wrestling when hijacking a UFO or an Archon.