You can ask.
If you have good connections, that might be granted.
Or you could play another game:
Search around for other projects and bosses, and try joining another project.
If you are truly correct, in that you are not really needed anymore, managers should be willing and maybe even excited to get you into a project where you make a bigger impact.
Ideally, the lead of the other project requests you.
Look at this from the higher ups perspective.
Possibility 1: You complain and demand a transfer. If they don't really know you, they now have to judge if you are right or right enough. It's very likely your word against your direct managers.
And since managers are well managers, and not judges, they usually view things through a business lens and not a justice or truth lens.
So even if they decide you are somewhat right, but your direct manager gets results, they might decide you are a trouble maker for not playing along.
Since you ask here if you can demand that, you clearly don't know how they will react. So this is a gamble.
You arrange to be transferred. The need in your current team is low, and you and the manager of the new story can tell a story how the transfer is totally beneficial for the company overall.
Now this is a standard business decision for the higher up -> do what's best for business. You just made sure that this aligns with your interests. No need to talk bad about your old manager, no bad aftertaste.
This also has the added benefit that ideally, the other projects manager does all the convincing for the higher ups. As manager, they should know how to best do this. Depending on the company, this may take days or months. But they will do it, all you have to do is to occasionally nod and say: "Yes, I also think the company benefits from me switching projects and I'm excited to do so".
Your current manager may even get praise from this:
They managed the project so well, they now need less headcount.
This makes it even easier for your old manager to let you go (and harder for him to keep you).
If this happens, just nod along. Resist the urge to contradict it.
View it as something that makes your transfer easier!
Now, how do you go about this?
Depends on the company. Ideally, you know someone directly. Either you know somebody in another team who can recommend you to their lead. Or you know another lead you can talk directly too.
Maybe from lunch breaks, maybe from company events, maybe from past meetings.
As fallback, check if there is an official board or something where the company announces possibilities of internal transfer.
Or check if there is a job on external sites that would match your skills.