I'd call it "teasing" or "play" rather than "trolling". Trolling has a bit of a mean connotation to it where as teasing/play is more, well, playful.
But, yes, after a certain point babies/infants do understand teasing play. That's essentially what games like peek-a-boo are. Babies don't have real object permanence until they're 8-12 months. That is, they don't fully have the ability to recognize that a thing still exists when it is not within their site/sensory perception until they're 8-12 months. (It gradually develops, so they'll gain more and more object permanence as they get older rather than just turning on all of a sudden.) When you play peek-a-boo, you're using this lack of fully developed object permanence to tease them. They won't recognize it as teasing at first, but they get it pretty quickly. That's why they laugh and have fun with it.