This question already has an answer here:
I have two sons now, one is of my former husband's side and older than the second son of my side from matrilineal marriage. The first son won't leave the succession line. I can't conspire to murder him since he's my child.
What must I do to take him out and bring my second son forward?
EDIT. A bit of update, that stupid non-dynastic heir somehow inherited a petty kingdom nearby, meaning he was not of my court anymore, there was nothing I could do. I could not ask him to take the vows (since he's not my courtier), couldn't imprison him though I was willing to suffer the opinion penalty. I tried to fabricate claim and declare war with hope to capture him as POW but wasn't a success. He took over the kingdom after my passing, leaving my dynasty to oblivion shame and putting an end to yet another noble house that couldn't survive the feudal hardship.