D&D 5e monster and villains are rarely, if ever, built like Characters, and this is actually a very good thing for you. That said, you need a starting point.
Start with the Archmage from the NPC Section of the DMG
It's easiest to work from a point that is close to your objective. The Archmage is a level 18 wizard (CR of 12). This is close to what you are looking for for a baseline, though you will likely have a lot of work to do to make him a challenge for the players.
In order to alter him properly to provide a challenge, you will want to look at several approaches.
Increase his level
Advancing him to a level 20 Archmage will not be too difficult in and of itself, but will only increase his CR by 1 or 2 points, so you will want to adjust fire from there.
Give him minions and guardians
Typically a creature that powerful will have loyal followers. Don't have him fight alone. Whether he has charmed an army of goblins to fight at his side, summons minions, hired a band of mercenaries, or simply has a loyal warrior that defends him, he will be highly benefited by having a few allies to keep his enemies away from him.
Make him tougher
In spite of the addition of allies, you can make him more resilient in several ways. Have him use clones or simalucra to make him stronger (via self-resurrection or duplication of his abilities). He can polymorph into something more dangerous, he can have spells that provide extra (temporary or real) hit points, or you can simply fudge it and give him more hit points. This won't address the next issue, but it is a start.
Give him extra spell slots of higher level (this can represent the scrolls I mentioned previously).
Make him Legendary
One of the biggest problems is that he will only act, by default, one to two times per turn. Since he is a boss, treat him as such. Those monsters in the MM that best reflect this are legendary monsters. Dragons, Liches, Beholders, Unicorns and more have both legendary actions and lair actions that can reflect an amazing boss encounter, and these can be used creatively to expand on what you have, making him formidable.
He doesn't have to follow PC rules, after all. I did this with a pirate captain, using his ship as his lair and giving it lair actions (that were basically things like the ship rocking from cannons going off, him tripping traps, etc). I also allowed him to do this through legendary actions for different types of traps, pitfalls, etc that he activated by 'pulling ropes' and 'flipping levers' in response to the player's actions. This made him seem like a master of his domain and added a lot of depth to the fight.
Ensure intimate knowledge of his skills
Have him use clones or simalucra to make him stronger (via self-resurrection or duplication of his abilities).
Pay attention to preparation spells... Especially if the wizard has access to decent abjuration spells. He should be prepared for the party... He should use scrolls to pre-buff for the fight, and Contingency to back him up. Hell, he likely has Wish in reserve. (Contingency on a teleport to get him out of Dodge when his hp gets low can frustrate the players, and make them have to face him again in another area of his domain, if you desire.)
Ensure you know what he is capable of... Should he be countering the party's spell-casters? (Counterspell as a legendary action/standard reaction would be particularly useful, but is easy to forget in the thick of battle.) Additionally, using Dispel Magic can cause the Wizard to debuff the party, thus taking away some of their edge.
Ultimately, an unaltered, lone, level 20 wizard is unlikely to give much pause to a full group of level 15-17 adventurers, assuming they rush quickly in to battle due to low hp of wizards in general. A little preparation to keep the Wizard out of the front lines, and some special abilities can go a long way to make a memorable encounter.
With the above, I am not stating that you should add extra hp to the wizard. His minions, magical traps, and prepared spells may (and possibly should) be enough to make him formidable regardless. Build him how you need him to function, but ensure you keep a truly broad scope of what can be done to increase the potency of a major enemy. 5e has tons of ways to modify monsters based on the rules for them and your campaign's goals.