Not only should he have heard it, he should have had a LOT of notice.
I'm using DnD Beyond for the description's wording here, but it'd be similar in the books as well:
Blazing green flames and mad, echoing laughter surround an undead flameskull.
First, the light of the Flameskull would be a sign that something is amiss.
Green flames don't generally happen with torches under normal circumstances. It's not that it can't happen, but it's unusual enough that any adventurer, let alone a Ranger, would be more than capable of telling that something is wrong and they should stay on guard.
Let's not forget the Flameskull is self-illuminating.
Depending on how dark the cave was, your Ranger should have been able to make out quite a few decent features of the Flameskull from that distance because of the flames and the fact they wrap around the skull, keeping it well-illuminated. I could understand if the Passive Perception was 16 or under, but your Ranger had a Passive of 26 and the object in question was within 30 feet. Your Ranger should have been able to tell you how many teeth were still in the Flameskull's mouth in those circumstances.
Finally, the "mad, echoing laughter."
Your entire party would have been able to hear this echoing through the environment. Presumably, the party was in the Underdark, which is a sprawling network of caves/caverns/etc. The laughter would have been heard by most of the party before the light could be seen by even your Ranger. If your party is someplace like the Underdark, they'd have a general idea of what to expect and, as a result, would know not to take sounds like that to mean anything less than trouble.