I’m sorry to hear how ill your dog is.
This simple answer to your question is “yes”. Heartworm infestation in dogs can lead to heart failure and heart failure can result in fluid accumulation. This is called oedema. The oedema can occur in a variety of sites with heartworm disease. It is not always a feature but often it is. The fluid accumulation can occur in the abdominal cavity, so that is not technically the stomach but the overall appearance will be that it is.
I hope your vet is able to stabilise his condition.
Good luck, regards, Peter