In SM/USUM, wild Pokémon can only have their HA if it is called in an SOS chain of at least 10. Other methods of obtaining HA Pokémon in Gen 7 are by breeding a Pokémon with its HA (HA parent must be same evolutionary line as offspring to pass the HA), event giveaways, or, in USUM only, receiving certain totem Pokémon. Pokémon from Poke Pelago do not have a chance to have their HA.
Source
Your comment suggests you don't know about chaining. Chaining through an SOS battle is the most effective way in Gen 7 of getting the HA for Pokémon you don't already have. Most wild Pokémon (with some exceptions) can call allies of its own species / evolutionary line. When enough Pokémon have been called in a single battle (chained), new allies start having a chance of having a HA (up to a 15% chance), among other benefits.