NEW YORK — Imprisoned financier Bernard Madoff’s longtime secretary defended herself from the witness stand Monday, telling a Manhattan jury about a 40-year career working unwittingly alongside a historic Ponzi scheme that began when she recognized through Madoff’s stutter on her first day that he wanted a ham and cheese sandwich for lunch.

“He gave me a thumbs-up and said: ‘You’ll do really good here,’ ” Annette Bongiorno recalled as she became the second defendant to testify among five defendants charged with helping Madoff cheat thousands of investors of nearly $20 billion. She said she could figure out what Madoff wanted through his stutter because a family member had one, too.

But she insisted repeatedly under questioning from her attorney, Roland Riopelle, that her ability to decipher unspoken words stopped short of realizing Madoff’s fraud in an office where Madoff, Bongiorno and their colleagues often repeated his mantra never to speak of his operations and his work on behalf of clients.

The fraud collapsed in December 2008 when the former Nasdaq chairman confessed to family and the FBI that his seemingly endless ability to turn double-digit profits for his investors was phony and his accounts were nearly empty as scores of investors frightened by the economic collapse demanded redemptions. He is serving a 150-year prison sentence.

Just after Bongiorno went to the witness stand, her lawyer asked her if she knew her longtime boss was running a Ponzi scheme. “Absolutely not!” she said firmly.