Here is a simple way to add temptation and willpower to a 5e D&D game in a meaningful way:
Whenever a character's flaws might be relevant, or when they're presented with a temptation, have them roll an appropriate mental saving throw. If they fail, give them a choice: They can either give in to the temptation (possibly telling a story about how exactly that happens), or lose a hit die or 1d4 hit points to overcome the temptation through willpower. Stronger temptations can have a higher penalty to resist.
(Outside the dungeon, a kobold outfitter is selling supplies. What do you do?)
Like many of my innovations, this was the result of an in-game inspiration. Recently I ran a game with a 9-year-old player and her parents (who were old gaming buddies). Her parents helped her build a character, using my random generation system, but she knew nothing about the game. I wanted to prevent boredom by starting her playing the game immediately, introducing mechanics only as necessary. So we started with cooperative story time for a while, with me introducing the setting and the players introducing their characters. Then, after maybe 15 minutes of role-playing, an opportunity came up for me to introduce the concepts of saving throws and hit points. I think it worked quite well as her first D&D saving throw.
She had rolled up a character with the urchin background. The people giving the party their quest were in the calligraphers' guild, and it was a busy place with lots of potentially valuable things to filch. So I told her to roll a wisdom saving throw, and explained how to do that. She failed. Then I described the temptation and asked her if she wanted to give into it and steal some items, or spend a hit point to resist. I explained that hit points were a combination of physical health and mental stamina and energy and focus. She chose to resist, and lost one hit point.
Note that my system never actually takes agency away from the player. She still has a choice about what to do; I think it is very important that the GM never dictate a character's actions or thoughts. But a character's flaws should matter. It is not realistic to assume that players have infinite willpower to overcome their desires and impulses. Some players are good about making the flaws matter, but others just ignore them, especially in high-stakes situations.
I like the elegance of this rules tweak, and I plan on using it a lot more in the future. Many RPGs have special systems for handling temptation or willpower, but I do not like adding new mechanics. It adds unnecessary complexity. I do, however, like being flexible with the definitions of things.
After thinking it over, I raised the hit point loss to 1d4, rolled after the choice is made, in order to make it riskier and more expensive to resist temptation. As characters gain levels, the temptations can become larger, and the cost of willpower gets larger.