Most of them have no idea. We had 2 dogs and one died. We left the dead dog on her bed on the porch overnight so our other dog would understand what happened. He watched us bury her and understood.
When my partner died his dog (my dog now) was waiting for him at the door all day long. I insisted the dog see him. After the autopsy- in a few days, I brought the dog to the crematorium and let him sniff my partner's arm. Then he knew. If I hadn't done that his dog would have been waiting for him to come home for his entire life. I wasn't about to do that to him.
If a person dies and has a very attached well behaved dog then I'd implore anyone to let the dog see the dead owner. They deal with things as well as anyone else, and it's only fair. You would want to know too.
EDIT; a lot of people have mentioned a dog; Hachiko, who never got over his owner being gone and kept waiting for him. My dog understood, was devastated, and then got over it and now lives his life without that kind of stress. He knows.
Here is a photo of my dog soon after his owner died, His eyes look kind of dead to me. And then another two of how he is now. He still gets sad occasionally, especially if I mention my partner’s name but he’s able to have fun and lead a full life now. It took him about a year to adjust, he was very attached to my partner
Lynn Harrington, enjoys irony and laughter