Acknowledge their loss but keep it short and simple.
If the grieving person wants to speak more, they will let you know.
Rambling on isn’t great but saying nothing is even worse.
The grieving person knows it’s awkward for you, and they’ll forgive a well meant fumble.
Silence, however, will be remembered forever.