The best build for a rogue in D&D 5E if they are playing a mastermind build is the skillful dodger.
The best way to play a mastermind character is to be sneaky. That means that it’s usually better not to fight, and instead escape or outwit your opponents. If you can’t do that, then try hitting the enemy with knockout poisons and knock them out before they ever hit back. Being able to dodge is among the most important things since you will need it all the time at low levels when enemies take attacks of opportunity against you while you sneak around, but also as an escape mechanism after thieves’ tools breaks and somebody starts chasing after you. Finally, being able to use disguise magic allows you to disguise yourself as someone else, which can be quite helpful if you’re trying to frame somebody else for your crimes.
The rogue has the best skill list in D&D 5E, but it also has the worst ability scores and only 1d8 hit points. This means that there are many different builds that can achieve similar things. For a mastermind, it’s probably best to consider the skillful dodger build, but other rogue builds such as the thief and burglar (which use Dexterity for their skills) could be pretty effective too.