The boat was carrying 42 people, all of them Sudanese, and two people were rescued, the judge Farid Ben Jha said.
Tunisia replaced Libya as north Africa’s main departure point for people fleeing poverty and conflict elsewhere in Africa and across the Middle East in the hope of a better life in Europe.
The country has seen a record wave of migration since last year, with frequent catastrophes involving boats sinking off its coast as they carry migrants from sub-Saharan Africa hoping to reach Italy.
In 2023 the Tunisian coast guard recovered the bodies of nearly 1,000 migrants drowned off its coast, Tunisian officials said, more than in any other year.
Tunisians have also been among those trying to make the crossing. About 40 Tunisian migrants went missing last month after setting off in a boat towards Italy.