قَاضٍ is related to قَاضِي. In the regular indefinite nominative and genitive forms, the final yāʾ is dropped and a kasra tanwīn remains.
The spelling of جَاءَ قَاضٍ and مَرَرْتُ بِقَاضٍ is the same, but the former is nominative and the latter genitive.
Caution: Kasra tanwīn here does not prove that the noun is genitive; check its syntactic role.