Generally it's a sign of immaturity to troll, as getting pleasure from the suffering of others is a sign you don't understand or respect people as much as you should. The threatening in real life is just as bad though.
"okay" as in allowed? No, not really. Light-hearted teasing among friends is very different than trolling/bullying for whatever reason. The difference is friends are in on the joke. If they're not in on the joke, you're probably just being a jerk. And yes, that includes "pranks", "trolling", etc.
Definitely don't troll. It's part of what separates adults from kids.