The musician will appear in a strip alongside the publication's mascot Desperate Dan in the last-ever print edition of the anthology, publisher DC Thomson has confirmed.
McCartney, who will be depicted leading 50 of the comic's most iconic characters in a rendition of 'Hey Jude', admitted that he has fulfilled a "personal ambition" by appearing in the comic.
"I feel a little sadness that I see its final issue is appearing in December," the former Beatle said in a letter. "In 1963, in the NME, when asked what my personal ambition was, I replied, 'To have my picture in The Dandy!' I hope it's not too late!"
McCartney is said to have contacted DC Thomson about appearing in the comic after learning of its discontinuation in August. The title will continue to exist as an online publication.
The final issue of The Dandy arrives in stores this week.