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 United States 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 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.