Legal implies that there’s a law or statute prohibiting certain behavior. For example, there are written laws prohibiting murder, assault, and driving over the posted speed limit. So what you are asking is this: Is there a written law prohibiting a consultant from withholding a password from a client (Or something more general). Would the police come in and arrest him for this?
Imagine this scenario:
"Hello, Police Department. This is John Q. Customer. I want to report a crime. Charlie Consultant won't give me my password. Will you please arrest him?"
Well, suffice it to say that a call like that would make the rounds among the police officers, but not as a crime to be dealt with, but rather a joke they could all laugh about. So no, it is not illegal.
Now libel, that's another issue. Could John Q. Customer bring a lawsuit against Charlie Consultant and ask for civil damages? Sure he could.
Imagine this scenario:
"Hello, Larry Lawyer. This is one of your clients, John Q. Customer. Charlie Consultant did some computer work for me, and he won’t give me my password. I'm not going to pay the bill until he does, but he won't give me the password until I pay the bill. In the meantime, I was denied access to my server and it prevented me from doing such and such, and as a result I lost some business. It cost me a lot of money in revenue. Can I sue him for a million dollars to recover the damages I incurred?"
Needless to say, some lawyers would salivate over a call like that (since they get a percentage of the damages), and a lawsuit could be filed in civil court in a heartbeat - if, of course, the claim has merit.
But my guess is that your boss would say, “I don’t give a rat’s behind. Let the jerk sue me.”
Bottom line: Do what your boss tells you to do unless you want to risk losing your job.