The definition of a 'Mary Sue' as most literary Internet denizens know it is something like this: "A character with no apparent flaws or difficulties during their adventure, and if they do run into conflict, they are able to breeze through it with no actual concern, on the part of the readers, whether they will make it or not." As far as I can tell, it has nothing to do with having a character who is morally perfect.
Okay, so take a 'perfect' character in the sense that they always do good in every situation. This is not necessarily bad! It's why Superman lasted so long in the olden days, before they introduced his whole World of Cardboard stance and other things to make him more appealing compared to, say, Batman (the poster child of Dark Superhero). It doesn't matter if their morals are always clear. What matters is if there is something, anything, in their personality that can provide a major flaw.
Now, people read stories for two basic reasons: to learn to like the protagonist, and to see if the protagonist succeeds.
Say, for example, your fledgeling Trainer character has strong moral values... but is absolutely horrible at Pokémon battling. Now, just because a person is completely good morally does not mean that they can't have a boring personality. Let's say that your Trainer is very funny, and he genuinely makes the readers like him. Ta-da! There's step one to making a good character. Here we have a guy who is perfectly moral, but is still fun to read about, because the reader base genuinely likes him. On the other hand, most Mary-Sues do not have a well defined and likable personality -- they have one or the other. Either A, their personality is generally nice and pleasant but has no depth to it; or B, they have a very distinct personality but it's not one that readers like.
Now! Just because the character does good in every situation does not mean that they will succeed! Our Justice Trainer will have problems fighting against the evil team or other villain of the story, because as we mentioned, he is very bad at Pokémon battling. It will not be clear if he succeeds or not, because his lacking skills in Pokémon might mean that he could actually lose this one, or the next one, or the one after that. Again, most Mary Sues do not have the readers asking that question: "Will he succeed?" If Justice Trainer were a Mary Sue, we would be told in the beginning of the story that he has no skill with Pokémon battling, but he defeats every villain he comes across with ease. That, to readers, is boring. There's no reason to keep watching him if we know he's going to win every time.
So there you have it. It's perfectly possible to have a character who is morally perfect and not a Mary Sue, as long as you make them enjoyable to read about, and give them other character traits besides their moral greatness that creates challenges for them to overcome.