Not at all! In fact, for trainers, it’s (unfortunately) a status symbol. If you own a legendary, that broadcasts to others that you’re a strong trainer who may put up quite a bit of a challenge on the battlefield. For this reason, not only are there no laws in place stating you can’t capture a legendary, but also, the training community often encourages you to try.
Of course, “encourages you to try” is the key phrase there. It’s often difficult to capture a legendary, and many of them are innately linked to their respective elements—sometimes to the point where removing them from the wild may do catastrophic damage to the world at large. Luckily, many of these legendaries put up quite a fight, never mind the fact that they’re often extremely difficult to find in the first place.
It’s also worth it to note that, yes, in some cultures, it may also be considered taboo to do so. It will still technically be legal to capture a region’s legendaries, but the locals may not be so happy to see you do it. For example, nothing is stopping anyone from capturing Ho-oh, but to a Johtonian, attempting to do so would make you an incredibly arrogant human being unless Ho-oh itself has deemed you worthy enough to train it.
In other words, it’s not illegal, but the locals may not appreciate it, no.