Yes, you can. But that doesn't mean you should.
I'm not aware of any mechanic in Pathfinder by which a shifter can change classes when they change form, and I'd be very surprised if there was one - it defeats the purpose of a class-based system.
However, you're the GM. Your primary responsibility is to make a game that's fun for everyone. You can definitely break the rules in the service of the story, to that end. (You can do almost anything, assuming your players don't object.)
But breaking the rules comes with a price - especially in a case like this, where you can't get player buy-in before you do it. You're eroding the predictability of the world - making the players less certain of how it works. Handled badly, the players will feel that you "cheated" by giving them a villain that they had no way to beat. Even at best, it makes the players less certain of how the world works - something that you normally don't want. And then the players will want to probe at the edges of the change, until they do understand it.
(An example problem: what are you going to answer if one of the players wants to play a shifter who can do this as their next character? If a villain can do it, why can't a hero?
That way lies a great deal of future trouble for you.)
So before you do this, we should examine why you want to. What do you gain from allowing the villain to have every character class as needed?
Making the disguise more convincing
An obvious reason to do it: you want the ultimate villain to be, for example, a wizard, but the NPC to be replaced is a fighter. You want the villain not to give themselves away by having few hit points and missing easy targets, or being unable to use the right weapons.
This has a huge drawback - the players will feel, correctly, that you cheated. By giving the character abilities they shouldn't have, you're artificially removing their chance to spot something was wrong.
Instead, you could adjust the real class to match the fake more closely (cleric instead of wizard). Or have a villain who's come well prepared. There are many spells and items a wizard can use to close the gap with a fighter - ask a question here (or in chat) for some examples of how.
Creating a more flexible villain
Maybe you feel he needs a wider range of abilities to make the post-discovery plot and encounters work. Maybe you need divine magic for one encounter, and wizardly items for one of his evil plans.
In that case, don't give him more character classes - give him allies. An evil shapeshifter can persuade, con, bribe or dupe an amazing variety of people to his aid. Give him allies that can do everything you need him to do. That has the same plot effect as the extra character classes, with an extra bonus - now you have intermediate villains for the players to duel to the death, and fooled allies that need to be won back to their side. It gives the players things to do.
Making your villain more awesome
If this is your motivation, then just don't do it. The reason it's great to have awesome villains is because it improves the plot, and it makes the characters more awesome for fighting them. The purpose of your villain is to give your heroes cool things to do.
But that only works if he meets the heroes on the same terms. Not even terms - he's a villain; he'll cheat if he can. But he must live in the same universe, on the same rules. Otherwise he stops being a villain, and becomes an unavoidable natural disaster, like a tornado - something they can't understand and deal with, just endure.
Your villain is not your character. Players will always feel the desire to make their favourite character more powerful; a GM must resist that temptation. Awesome villainy comes from their personality and plans, not their range of class abilities.
If you do this right, it'll be the treachery and surprise that they remember. Play to that. Make him charming, smart, and capable of advance planning. (Make sure he's carrying a magical way to escape when first discovered.) They'll be talking about it for years.
The best reason to break a rule is if breaking the rule is, in itself, a part of your plot. Maybe an important element of the plot is that he is surprisingly able to shift class - because he's an advance agent for a powerful god of chaos that wants to change the rules, or abolish classes entirely. Maybe he's the destined messiah of all shifters, able to shift to become someone completely with all their skills.
If you're using the power for your plot, you can do this. Be sure there are hints as to the source of, and reasons for, his unique power. Done right, this could make for a truly epic villain. (Make sure he has some major weakness as well, or he'll be truly unbeatable - changing class on demand is a ridiculously powerful ability.)