A South African court on Wednesday ruled that displaying the country’s apartheid-era flag in public constituted hate speech that discriminated against black people and violated equality laws.