It's mostly a trial and error thing. It took me a while to pull it off in Trilogy, but I eventually did it at some point. Usually, though, I'll press up just before the hat reaches the opponent. All you can do is keep trying until it works, unfortunately.