After defeating Kahuna Hapu and completing your Island Challenge in Pokemon Ultra Sun, you will be able to find Solgaleo with Lillie on Mahalo Trail back on Melemele Island. Not being able to properly take care of Solgaleo like a Pokemon Trainer would, Lillie asks that you battle and capture Solgaleo so it can continue to travel with you.
Like many other Legendary Pokemon, Solgaleo makes for a very difficult capture. To start, odds are it will be equal or higher than most of the Pokemon on your team, sitting at a pretty decent Level 60. It will also probably be faster than most of your Pokemon, having a Base Stat of 97 (one of the higher speed stats for Alola Region Pokemon). And let's not forget the offensive power it has, plus its exclusive ability that prevents its stats from being lowered. Yeah, this thing won't be easy unless you're using a Masterball on it, which is never recommended.
As like most Legendary Pokemon that don't have the highest level within a game, you should definitely only try using Ultra Balls on Solgaleo, but only after getting its HP as low as you possibly can. This can be incredibly difficult, since it won't have any problem crushing all sorts of holes in your team as you do. And that's why you need to have more than the average amount of Ultra Balls, Revives and Max Potions when facing it.
False Swipe is also a nice move to have on one of your Pokemon, guaranteeing that Solgaleo will be left with at least one HP, should you have the TM or a Pokemon that knows it. Thunder Wave also works best as status conditioning to make Solgaleo easier to catch, since it's permanent (unlike sleep) and it doesn't cause Solgaleo to lose any HP. If you have the Rotom Power that makes it easier to catch a Wild Pokemon, then you should definitely consider using it here as well. And don't forget to ALWAYS save before facing Solgaleo. It's a safety precaution, one that has worked since the first generation of Pokemon.