Looking at it from another direction, HD and most other PC healing resources function to let the party handle a longer day - presumably, the 6-8 encounter/day point at which supposedly, the game aims to balance. Overnight healing, OTOH, is a complete re-set. If you 'penalize' retreat & short-rest by having the monsters benefit from HD, beefing up their defenses, gathering re-enforcements, "re-spawning" or whatever, then players have an incentive to either fight to death or to go for the full re-set of a long rest after retreating.
So it might make more sense to let players come back to relatively the same challenge after a short rest or any other disengagement short of a long rest, and only have monsters heal (and also bring in the classic D&D tricks of having more monsters & better defenses when the PCs return) when the players decide on taking a long rest before taking a second crack at them. It telegraphs that you intend to discourage the 5MWD.
FWIW.
From an entirely different perspective, OTOH, if the PCs are retreating, the encounter might have been too tough, while, if the monsters are getting away, it might have been too easy or just a lead-in to something more significant. In the former case, denying the monsters healing or having the wounded monsters desert might bring the encounter back down to a more reasonable level of challenge. In the latter, the old-school advice of doubling-down on numbers of monsters, levels of preparedness, &c makes sense.