Yes, this is very possible! Here's a tutorial.
The first thing you should do is
open the database.
Click the
"Common Events" tab as shown!

You will then want to
add a choice of which actor to use the item on (which you probably know how to do) and you can use conditional branches. For example, if you have this party character, you can affect them, but
if you don't, you can't. This can be done with variables or switches.
You then must have
another choice branch allowing the player to choose the class.

So, after the conditional branch is set up, simply choose
"Change Class" under the "Actor" heading and depending on which character and class the player chose, click the actor name and class. You'll have to put this in many times depending on how many classes and actors you have, so that
every choice results in the right actor change.
Be sure to
save the common event and name it if you want to. Then, go to the
"Items" tab and find your potion or item that allows the character to change their class. As shown in the following screenshot,
click a bar under the "Effects" heading and choose the common event you just made.

And there you have it. A potion/item that can change any actor to any class.
I hope this made sense! Not used to making lengthy tutorials.
If you are confused at all, let me know, and if there is an issue/ if this is not what you wanted, also let me know and maybe I can help.