I was once in a similar situation. Even if you could imprison and even banish your son, he would still be your heir. You could execute him, but I've found it to be an unpreferable choice due to the penalties (-10 Opinion from all vassals, -20 Piety).
It's possible, but there are no guarantees for success. Here's a few things you can do:
- If your king is old, frail and likely to die soon, you could still
imprison and execute your son, even if you have no moral right to do
so. You will get severe penalties to the opinion of vassals and lose
a bunch of piety, but you will be certain it will work. Having your son excommunicated first will eliminate some of the penalties. Can be used
- Make him lead an army of only a handful of men, preferably not a very skilled troupe. Throw him against far superiour forces, and hope he gets himself killed. If he gets imprisoned, you could either refuse to ransom him out (in my experience, prisoners often die in custody) or bail him out and send him on more suicide missions.
- Give your preferred son a whole load of powerful duchies. If everything goes well, this will start a succession war once you die. You will then play as the imbecile. Make sure you lose. This option will probably not work in gavelkind succession, since they prevent you from actively meddling with the succession too much this way.
- You might also consider changing your succession law to elective, however that might backfire if you don't have enough votes or the ability to make vassals point at your favourite candidate. It might also be messy if you rule more kingdoms.
- In old versions of the game (v1.x), you could disinherit anyone by appointing them bishops. This exploit has since been removed, but if your save game is very old, there might be hope still. This is definitely the easiest and most efficient way to disinherit someone.
You can also do the second option if he actually does inherit. If he dies as a ruler, his eldest brother will probably inherit, so long as your succession laws allow it and he hasn't fathered any child of his own.
Similarly, you can actually commit suicide, provided he has the depressed trait. If he hasn't fathered any children, your titles should go to one of his non-imbecile siblings.
None of these options are sure-fire, of course. The sooner you start working on the untimely death of your heir, the better.