This little guy is so annoying. I caught a shiny Trumbeak (my first shiny ever obtained) and KOed, like, 5 heracross, which supposedly had the same chance of being obtained as Riolu. I've tried hunting in the day and night, but still no luck.
Riolu can only be found in Poni Grove in Ultra Moon. Source: https://m.bulbapedia.bulbagarden.net/wiki/Riolu_(Pokémon)
In Poni Grove, it has only a 10% chance of being found during the Day only, not at night. This leaves you 2 options. 1. Do wild encounters during the day until you find Riolu. This shouldn't be hard because 10% is still a decent encounter rate. 2. Trade for Riolu with a friend or on the GTS. This isn't as desirable as people make absurd requests.
Conclusion: Just continue to do Wild Encounters until you find a Riolu. You shouldn't expect to find it after 5 encounters due to the lower encounter rate, but it shouldn't take an extremely long time. Source: https://m.bulbapedia.bulbagarden.net/wiki/Poni_Grove