The Federal Constitutional Court's ruling came after a Frankfurt-born German-Moroccan legal trainee filed a challenge to Hesse state's rules.
In the western state, trainees who keep their headscarves on are not allowed to take on tasks in which they may be seen to be acting as representatives of the judiciary or the state.
This means for instance that headscarf-wearing trainees are not allowed to sit on the judges' bench as they observe proceedings like other trainees, but would need to follow the process from the floor.
Likewise, they are not allowed to take evidence or lead hearings.
Thursday's ruling was expected to impact a wider debate on the issue in Germany, where around 4.5 million Muslims live and where rules on use of the hijab headwear differ between the 16 federal states.
German national law bans all civil servants from covering their faces, including with Muslim niqabs and burkas — except for health and safety reasons, such as fire-fighters wearing breathing masks.
But there is no nationwide ban on civil servants wearing the hijab and many states weigh the trade-off between freedom of religion and civil servants' neutrality rules on a case-by-case basis.
A Berlin labour court in 2018 barred a teacher who wore the headscarf from teaching primary school classes, but found the she could continue teaching older vocational students in a public secondary school in the German capital.