This is an ancient superstition and by using the word “superstition” you can see where this brief article is going. A dog howling does not presage death. Dr Desmond Morris comes up with a plausible theory for the origin of this superstition. He refers to an anonymous authority to add more mystery.

When a dog has rabies he/she howls and whines and make strange noises. People cannot fail to notice, he says. The rabid dog then infects his owner who dies. People get wind of the story and it is interpreted as the dog having supernatural powers and being able to predict the death of their owner. The unusual sounds that the dog made adds to the mystery.
During this ancient era when the superstition developed the mode of transmission of infectious diseases was completely unknown. This makes the theory plausible.
According to statista.com, in 2020, about 30 percent of the population in the USA are either somewhat superstitious or very supersitious. I am sure that the statistics are similar for any country and higher in some such as on the African continent. These supersitious beliefs probably extend to believing that dogs have supernatural powers enabling them to foresee the future. Superstition in general is still alive and well. People like to find explanations for things they can’t understand and superstition fills the void.
People also tend to be selective. There are probably millions of examples of dogs howling and nobody dies soon afterwards. I have written about the dog howl, which you can read by clicking on this link. Dogs howl when they are lonely.
I suppose that strange noises in addition to the howl made by a rabid dog encouraged the belief that the dog was foreseeing an impending death.