The mentor’s function in a story is a simple one; to instruct the protagonist on how to reach their goal. Every story has a mentor in some form such as Obi Wan Kenobi in Star Wars and Master Shifu in Kung Fu Panda. They can be anyone, even the antagonist like Reverse Flash in CW’s The Flash TV show. They can either be characters who don’t do much other than teach the protagonist such as Yoda in the original Star Wars trilogy, or they can play a major role in the protagonists journey such as Dumbledore in Harry Potter.
What you have to decide when writing such a character is who they are. What type of personality will they have? Will they be perverted such as Master Roshi in Dragon Ball? Will they be cowardly or overconfident or suspicious? How will they aid the protagonist? What will they teach the protagonist? After you have thought of these things you are almost ready to start writing the story.
Of course you should probably make sure that they are at least moderately developed before you begin actually writing as the mentor character should never be completely flat. They can be as round as an embossed plate, but not any flatter than that.