The third installation in the series has been shot in 3D for the first time and will be premiered at the Cannes Film Festival.
"Katy just recently recorded a special number for Madagascar 3. The song which is upbeat will be used for the climax sequence of the film," a source said.
The film opens in theatres worldwide on June 8.