How do I make a player's nametag in chat match their torso color?

Pretty simple issue
Trying to make a system where in the chat where the player’s name in chat matches their torso’s color. But I don’t know how to edit messages to set the name’s color to their torso.

Text
^ This should match the player’s torso color

To my knowledge, it is not possible to do so. Not very easily at least.

This post from a very long time ago should help, however.