The 'Firework' hitmaker will play Honey, the beautiful and naive cousin of architecture student Zoey (Jennifer Morrison) in one episode of the US sitcom.
No other details of Katy's role have been announced but she is expected to make her appearance during the show's current season.
Katy will not be the first pop star to appear in the series.
Britney Spears won praise from the cast for her guest appearance in 2008, with former 'Buffy the Vampire Slayer' star Alyson Hannigan - who plays Lily Aldrin ' describing her as hilarious.
She said: "[Britney] was so funny, and she already had her character down pat. I had no idea she had such great comic timing."
Pussycat Doll Nicole Scherzinger appeared in the sixth season of the programme as singer Jessica Glitter, who used to perform unintentionally erotic songs on a Canadian children's show with Robin Sparkles (Cobie Smulders).
Both Katy and 'How I Met Your Mother' were victorious at the People's Choice Awards in Los Angeles last night's (05.01.11) with the singer winning prizes for Favourite Female Artist and Favourite Online Sensation, while Neil Patrick Harris picked up the Favourite TV Comedy Actor accolade for his role as womanising Barney Stinson in the sitcom.