I’d need more context to give you a real answer but personally:
Do it like any “we need to talk” adult talks, keep it simple explain what happened, give age appropriate details, and tell them it’s ok to cry/be mad/be sad for a long time, etc. encourage them to express their feelings in that moment and then in recovery share with them when something reminded you of the pet or things related to the pet, it seems counter intuitive but they are having these same thoughts and feelings and by saying them out loud you’re saying it’s ok to feel this and we can grieve together.
Hope this helps
It think it’s important to plant this seed early, I would always joke about how the dogs are here “for a good time not for a long time” when my kids were growing up, it also encouraged them to live in the moment with our pets. Speak openly about the dog aging like you might to an adult peer, that way your child learns these scary thoughts are safe to have and you share them too so they can come to you for comfort. Obviously this is age appropriate advice little kids don’t need that last part.