In mainline Pokémon games, Master Balls are extremely rare and cannot be farmed. Obtaining additional ones is limited to:
No "trick" or exploit exists. They are designed as the rarest item, meant for the hardest catches.