In a video posted to Instagram on Friday, the 35-year-old star is seen rehearsing the "secret" tune while on an elliptical machine.
"Listen to meeee gee wiiiizzzz," McPhee captioned the impressive clip. "I’m singing a new little secret song that David wrote for something special during my vocal exercises today with @amychapman.
"Don’t judge me!" she added.
For the rehearsal, McPhee rocked a blue tee, denim cut-off shorts and a pair of white sandals.
McPhee's social media followers were quick to notice the "American Idol" alum's skills, applauding her in the comments section.
"You are a 🎁,” wrote "Real Housewives of Beverly Hills" star Lisa Rinna. While Kristin Chenoweth said she also belts out songs when exercising.
"I sing all the time on the treadmill," Chenoweth admitted. "Good for our lungs!"
McPhee and Foster, 69, tied the knot at a church in London back in June.
“It was a gorgeous ceremony," a source told Fox News at the time. "You can tell a lot of thought and care went into making sure everything went perfectly without a hitch."
For the special day, McPhee wore a custom-made gown by Zac Posen. She "looked stunning," said the insider, adding that the actress "struggled to fight back tears."
"Her special day finally came and it was everything she could have imagined it would be," continued the source. "It was a long time coming and this one just felt right to Katharine.
"Regardless of what other people have said about her and David’s relationship – it was more than a decade in the making and she’s happy."
Fox News' Julius Young contributed to this report.