A simple “I'm sorry for your loss” is fine if you don't know them very well. However, it's often better if you can say something about the person who has passed away. Saying something personal that kindly remembers the person and what they meant to you is very much appreciated.