Start with acknowledgment
Say something simple without asking them to manage your response.
Name the loss, include the pet's name only if it was shared, and remove pressure to reply. Avoid trying to explain the grief away.
I'm so sorry about [pet's name]. I know how much they meant to you. I'm thinking of you, and you do not need to reply.