The judiciary is going to be a civilian organisation that is not directly controlled by the duke. It will do its job to ensure that the law is followed and anyone caught breaking the law is punished. This also applies to people with high ranking titles so it is possible that the duke could end up in prison if they are found to have committed a serious enough crime. The judiciary will be funded by the duke (along with the prison system) but will be run by a separate group of people who will have been chosen by the populace because they are trustworthy members of the community who people feel like deserve such a commanding position.
The judiciaries primary task will hear the evidence of the police as well as the testimony of the accused and to then decide whether they deserve prison or not. A jury will determine if they are guilty or not first.