What is the best build for a rogue in D&D 5E for a mastermind build?
Rogues have the widest array of class skills and subsequently, they can excel in a wider variety of builds. That being said, there are many different types of mastermind rogues out there and there’s no “best” answer as each build has its own set of pros and cons.
There are some very strong arguments to be made for Nightstalker for stealthy infiltration into unsuspecting communities that only find out too late who they’ve welcomed into their home or dungeon (detecting these rogues is not easy), Mastermind for switching stances between flanking opponents while keeping the rest at bay with metered bursts from sneak attack damage (masterminds get the most versatility with ability to grapple foes in fear-inducing manner), any number of hybrid builds that combine one or two of the above, and so on.
From a flavor perspective there’s also no “best” build. While many rogue players would prefer their character to be sharp-witted, charming, dexterous in combat while possessing superior knowledge in various fields to help further whatever agenda they choose to pursue (unlike wizards and clerics), there’s no explanation on why they can’t be all of these things while also being a supernaturally good fighter with an emphasis on speed (à la monks).
My personal recommendation is that you pick your favorite rogue archetype and focus on that. You can use one of the many tools available to optimize your character, such as this one which will tell you just how much damage you’ll be dealing on average with sneak attack.
In the end, all players have their own preferences and it’s up to them to decide what they want from a build. In fact, many of the most-used builds in D&D 5E were not even designed to be used by rogues in the first place (e.g., scout, eldritch knight).