This doesn't work, unless the DM wants it to work.
The conditions for triggering sneak attack damage are quite clearly spelled out:
Once per turn, you can deal an extra 1d6 damage to one creature you hit with an attack if you have advantage on the attack roll. The attack must use a finesse or a ranged weapon.
You don’t need advantage on the attack roll if another enemy of the target is within 5 feet of it, that enemy isn’t incapacitated, and you don’t have disadvantage on the attack roll.
The situation you describe does not sound like it lines up with the conditions. Nevertheless...
The DM can decide you have advantage.
The rules do not explain every possible circumstance that may grant advantage or disadvantage. To account for this, the DM is given discretion here. From the rules for advantage and disadvantage:
The DM can also decide that circumstances influence a roll in one direction or the other and grant advantage or impose disadvantage as a result.
At their discretion, the DM may decide that the circumstances warrant giving a particular roll advantage or disadvantage. It sounds to me like the situation you describe is definitely surprising, so advantage on the attack does not seem unreasonable, and would then trigger sneak attack damage.
This ruling is kind of lame because of misaligned expectations.
The reason you are asking this question is because you understand how sneak attack normally works, and the situation where sneak attack was used against your party member did not line up with that understanding. Your expectations and what happened did not line up. To be clear, this is not always bad. Interesting plot points that subvert our expectations are good. Subversion of expectations that lead to player characters dying are pretty cheap (in my opinion).
Most people don't go into the game expecting to cheap shotted by the DM, and this sounds like that is exactly what happened.
Moving forward, it may be best to discuss this move with your DM. This answer has some guidance for getting that ball rolling, and this article has some more in depth guidance to think about: What kind of game do you want to play?