Only 1 really, and it is ridiculously hard. ORAS has a second one as well.
Number One: In all of the games, there is usually a major department store. In there, or somewhere in the game, you’ll find a lottery corner, and if 5 of the digits of your trainer ID match up, you get one. IIRC, in some games it’s a Pokémon’s ID, so that makes it easier if you have more Pokemon, since each Pokémon has a unique one.
Number Two (ORAS): If you have a secret pal in your secret base with the ability “pick something up” there is a very tiny chance that they will pick up a master ball. But I don’t think anyone really uses secret bases anymore (or even when they were new) and you need to have a few friends to do this. Not to mention actually get a special rank for some characters, and that it’s dependent on the persons trainer class. Finally, you can’t even put this ball in Sun and Moon.
Hope I helped. :)
Sauces: https://m.bulbapedia.bulbagarden.net/wiki/Master_Ball (will till you where the lottery NPC’s are located.