The church’s highest court has ruled that the consecration of its first openly gay bishop violated church law, compounding a bitter rift over homosexuality.