How do you obtain Bottle Caps?

Solution 1:

Bottle caps can be found while fishing without too much trouble. They are not very common, but are easier to find than the 1% encounter if the fishing spot is not bubbling.

They can also be obtained in the Festival Plaza. Lottery Shops called "Treasure Hunt" have Bottle Caps as the second prize, and the more effective Gold Bottle Cap as the first prize. Whenever a Lottery Shop of two stars or higher is installed, going to the shop immediately and drawing a ticket will always result in getting the second prize, so that's a Bottle Cap from each Treasure Hunt with at least two stars that gets installed, even if it is installed by being introduced.

All Haunted House facilities can also give the player a Bottle Cap, but they are rare.

Gold Bottle Caps can rarely be found from Isle Aphun, found in the Path for Rare-Treasure Hunting. The Path for Interesting-Item Hunting can also give them if Isle Aphun is level 3, as it simply awards the player with items from all unlocked paths. Shards can be obtained from the first path unlocked on Isle Aphun, and 30 of the same colour can be exchanged for a single Bottle Cap by talking to an old man in the castle in the Festival Plaza.

If you go to the Battle Tree, then achieve a streak of at least 30, if you lose a battle and the streak ends the receptionist will give you a single Bottle Cap if you return on a later day. This can be repeated. If the streak went for 50, you get an Ability Capsule, too. PP Ups and PP Maxes can also be obtained from here, and this is how you get the Lansat and Starf berries, with the traditional streaks of 100 and 200 required.

Finally, if you go to Poni Gauntlet and battle all the other trainers there, you can fight Trial Captain Mina. When you defeat her, she will give you a single, once-off Bottle Cap, while the Magearna obtained by scanning the QR code (released) will be holding a Bottle Cap when you get it. If you want to choose the Nature of this Magearna, Synchronize affects it, and works 100% of the time to set the Nature.

Solution 2:

Based on this article

Hyper Training is found in the Hau'oli City Shopping Mall. Here, you can visit this shop and speak to Mr. Hyper and exchange Bottle Caps, in order to increase the IVs of your Pokémon. This can only be done if your Pokémon has reached Level 100.
There are two different kinds of Bottle Caps. The standard Bottle Cap will raise one IV to the maximum, and the Gold Bottle Cap will boost all six IVs to maximum. These items are quite rare, and can be more predominantly found through exchanging Shards for them in the Festival Plaza and through the Lottery Shops there.

The thing with Hyper Training is that the boost is superficial. The actual IVs of the Pokémon do not get increased, merely they give the appearance of having maximum. Due to this, the Pokémon's Hidden Power will remain the same as it always was, and the Pokémon, when bred, will not pass any maximum IVs as the Pokémon's IVs are still how they were originally. It factors in battle, but the IV does remain unchanged for all other purposes.

EDIT: Everyone who buys the game will be able to "redeem" a free Magearna and will be holding a Bottle Cap. Source

More about redeeming the Magearna here

EDIT 2: As pointed out by Kai and PartHunter bottle caps can be obtained(very rarely) while fishing. You can also get bottle caps as a reward once you attain a win streak of 30 in the Battle Tree.

Reddit - Hyper Training