The Taliban claimed responsibility for the attack.
The bomber, who was on foot, detonated his explosives' vest as he walked by the vehicle in the western part of the city, said Najib Danish, the Interior Ministry's deputy spokesman.
The attack came as the Taliban named a new leader following the death of their former leader, Mullah Akhtar Mansour, in a US drone strike in Pakistan on Saturday.
The casualties in today's bombing included both court workers and civilians and the explosion also wounded four people, Danish said.
More From This Section
Within an hour of the assault, the Taliban, who often target government employees in their war against the state, claimed responsibility for the bombing.
The claim came from Zabihullah Mujahid, a Taliban spokesman, in an email sent to the media.
"This attack was carried out as revenge for the killing of six innocent prisoners in Kabul," the statement said. It was a reference to the hanging early this month at a Kabul prison of six Taliban members convicted of terrorism.
The executions were the first approved by Ghani since he took office in 2014, promising to end the war. After the hanging, a Taliban statement accusing Kabul and the US of torture, inhumane treatment and "killings under suspicious circumstances."
The suicide attack in Kabul was the second of its kind on the judiciary this month - a judge was gunned down by unknown attackers in Kabul earlier in May.
The UN mission in Afghanistan condemned the attack. Since January 1, UNAMA has verified 14 separate attacks targeting judges, prosecutors and judicial staff in Afghanistan, resulting in nine civilian deaths and 19 civilians wounded.
"Attacks against judicial authorities are cowardly and contrary to international humanitarian law," said Nicholas Haysom, the chief of UNAMA, adding that the mission urges "authorities to do everything in their power to ensure adequate protection of judicial officials."
The last major attack in Kabul was on April 19, when a massive bomb killed 64 people and wounded hundreds. The Taliban also claimed that bombing.