Maybe a casual acquaintance who met Tom while shopping at Borgin and Burkes would have a hard time identifying Tom Riddle after his transformation, but Hagrid, an (ex)schoolmate and later a Hogwarts gamekeeper was more likely to recognise Lord Voldemort as Tom, the Slytherin prefect who got an award for reporting Hagrid for the crime he didn't commit and causing his expulsion.
As the Keeper of the Keys of Hogwarts it is possible he even met Voldemort when Voldemort returned to Howarts at ~1966 and visited Dumbledore, reapplying for the DADA job. Maybe Hagrid even was the one let Voldemort in. From the description it seems that at that time Tom was still less snakelike and still recognisable:
Voldemort had entered the room. His features were not those Harry had
seen emerge from the great stone cauldron almost two years ago: They
were not as snake-like, the eyes were not yet scarlet, the face not
yet masklike, and yet he was no longer handsome Tom Riddle. It was as
though his features had been burned and blurred; they were waxy and
oddly distorted, and the whites of the eyes now had a permanently
bloody look, though the pupils were not yet the slits that Harry knew
they would become. He was wearing a long black cloak, and his face was
as pale as the snow glistening on his shoulders.
The Dumbledore behind the desk showed no sign of surprise. Evidently
this visit had been made by appointment. “Good evening, Tom,” said
Dumbledore easily. “Won’t you sit down?” ~Harry Potter and the Half Blood Prince - Chapter 20 : Lord Voldemort's Request
Tom Riddle then had no restrains (re)introducing himself as Lord Voldemort, but if someone did identity him as Tom Riddle, he didn't deny it:
Voldemort did not answer at once, but merely sipped his wine. “They do
not call me ‘Tom’ anymore,” he said. “These days, I am known as—” “I
know what you are known as,” said
Dumbledore, smiling, pleasantly. “But to me, I’m afraid, you will
always be Tom Riddle.~ibid
So it is possible that Hagrid encountered Voldemort after he returned from his travels and was among the few who knew Voldemort was once called Tom Riddle.
I highly doubt that Dumbledore shared his suspicions with Hagrid about the identity of the Heir of Slytherin. After all, he had no proof. Not even when Hagrid showed up in Harry's second year, agitated, afraid that history may repeat itself and and the innocent (yet again) will be blamed :
...the door of the
office flew open with an almighty bang and Hagrid burst in, a wild
look in his eyes, his balaclava perched on top of his shaggy black
head and the dead rooster still swinging from his hand. “It wasn’
Harry, Professor Dumbledore!” said Hagrid urgently. “I was talkin’ ter
him seconds before that kid was found, he never had time, sir—”
Dumbledore tried to say something, but Hagrid went ranting on, waving
the rooster around in his agitation, sending feathers everywhere. “it
can’t’ve bin him, I’ll swear it in front o’ the Ministry o’ Magic if I
have to—” “Hagrid, I—” “—yeh’ve got the wrong boy, sir, I know Harry
never—” “Hagrid!” said Dumbledore loudly. “I do not think that Harry
attacked those people.” ~Harry Potter and the Chamber of Secrets - 12: The Polyjuice potion
Not even when the ministry officials came to take Hagrid to Azkaban did Dumbledore told them that back then Hagrid's accuser was in fact young Lord Voldemort aka Tom Riddle.
Dumbledore did not have proof of Voldemort's involvement until Harry returned from the Chamber with the Diary, and besides it seems he was pretty brisk with Hagrid, usually giving him simple instructions without lenghty explanations.
There are many possibilities beside the above mentioned chance encounter during Voldemort's visit: Hogwarts staff gossip, an overheard conversation (maybe even between Dumbledore and Slughorn), Voldemort's followers bragging about Slytherin being the best house the Dark Lord was in. .. or just some foggy rumors about You-Know-Who hailing from Slytherin House, without any specific information, which Hagrid shared with Harry when introducing him the wizarding world.