Tell them clearly that this kind of behavior makes you uncomfortable and violates your family's privacy. If they are real friends, they will understand and stop. If not, you should distance yourself from them. You can also make it clear that any stories related to your wife in a private way are not for sharing or amusement.
One way is to have a group talk with them. Explain that your wife is a person who deserves respect and privacy. Share how such 'stories' make you feel uneasy and angry. You can also give examples of how important privacy is in other relationships. Additionally, in your daily interactions, avoid any topics that could lead to such inappropriate discussions. If they still don't listen, it might be time to find new friends who respect boundaries.
Share some of the more general stories in a group setting, so they get their curiosity satisfied in a proper way.
Tell them directly that it's wrong and disrespectful.
Another option is to look at old photos or videos. Sometimes just seeing the visual of what was going on at the time can jog your memory about a great story. Maybe there's a video of a friend trying to do a magic trick that went horribly wrong. And this way, you can share these stories with your wife without causing any discomfort to your friends.
Another option is to share her interests. If she loves reading, you could mention how she has introduced you to some great books, and how she often organizes a small book club among friends. This way, your friends get to know her better in a positive and respectful way.
Just be honest with her. Tell her that it's inappropriate and goes against social norms and your relationship values.
Communication is key. Make sure your wife knows your boundaries and how you feel about her interacting with your friends. Also, choose your friends wisely. If you have friends who seem to have a flirty or inappropriate attitude, keep them at a distance. Set clear rules in your marriage about social interactions.
One important step is to build a strong relationship with your wife based on mutual respect and trust. When she feels truly loved and respected by you, she is more likely to respect your feelings regarding her interactions with your friends. Also, be involved in the social gatherings. If you are always present, it serves as a deterrent to any potential inappropriate behavior. And if you notice any signs of improper behavior starting, quickly and calmly address it right then and there.
If a direct approach doesn't work, you can try to limit his access to opportunities to share these stories. Avoid conversations where he might bring it up. If he still manages to, quickly change the topic. You can also create a situation where it becomes clear that you are not interested in hearing or having others hear these stories. For instance, you could say in a group setting (if he shares there) that you'd rather keep your family life private and not have it be the topic of discussion at work.
First, you should have an honest conversation with your wife privately. Explain to her how uncomfortable and inappropriate this behavior makes you feel. Then, you might also need to have a talk with your friends, making it clear that such behavior is not acceptable in your relationship.
Talk to them directly. Tell them it's unacceptable and they should respect your family. Simple as that.