Antonomasia. From Encyclopedia Britannica (bold emphasis added):
Antonomasia, a figure of speech in which some defining word or phrase is substituted for a person’s proper name (for example, “the Bard of Avon” for William Shakespeare). In fiction, the practice of giving to a character a proper name that defines or suggests a leading quality of that ...
It's called charactonym. From the link (Merriam-Webster dictionary):
Definition of charactonym
: a name especially for a fictional character (such as Mistress Quickly or Caspar Milquetoast) that suggests a distinctive trait of the character