Very severe diarrhea, of course, is concerning and should be checked out by a vet. I don't think guarding food and having diarrhea is particularly indicative of a dog who is dying, but of course, severe diarrhea, not eating/drinking can lead to progressive dehydration which can ultimately become life-threatening, so please consult with a vet to see what can be done to keep it under control. From personal experience, I can say that my dog, when she was diagnosed with terminal cancer, guarded her food from my other dog when she was still interested in it. Then, as her appetite diminished and became weaker, she mellowed down a bit in this aspect but I still used caution in preventing any possible resource guarding.
If your dog never resources guarded and now resource guards, it is possible that changes in the brain (as a result of kidney/liver failure, brain cancer, cognitive dysfunction in older dogs) may be taking place which can cause abnormal behaviors.
Another possible explanation is that you are offering high-value foods, that your dog cherishes and desires, but doesn't eat due to nausea/lack of appetite. Since the foods are laying around, and your dog has no interest in consuming readily, he may use his growl to inform other dogs or people that although he isn't eating it, he still wants to retain ownership of it. This mindset may especially occur when dogs are in pain or weaker and they feel more vulnerable since they may not walk around as they used to, so they use "their words" more since they can't just pick up the food and walk away.