Start with the simplest test available: if it frightens her, stop doing it. A toddler who is genuinely scared will carry that with her, and a habit repeated often enough can leave a mark well beyond the moment itself.
There's an important distinction hiding in the question, though. Startling — jumping out from behind a door, flipping someone upside down in a hug, dropping a cushion nearby — triggers a quick involuntary reaction, and most toddlers find it hilarious. Many will say "again, again!" within seconds. Scaring is different: it plants real fear, and the response is crying and wariness around the situation where it happened.
So watch the reaction, not your intention. Immediate laughter that turns into a request to repeat it points to a startle she's enjoying. Tears, clinging, or nervousness mean it's gone too far and should stop. When in doubt, leave the poor kid alone — there are far better games to play with a two-year-old.