There is a legal reason, several actually, and the judge used one of them. Equal protection under the law. However, the real reason this law should be struck down is that the constitution of the US does not give any legal authority to the government, local, state or feds, to tell us what to eat or drink or how much of it we can consume. The law is unconstitutional as are laws pertaining to smoking, guns and drugs.
By allowing the government to tell us what we could put into our bodies we opened a can of worms, now they feel they can regulate every thing we do, they simply don't have that amount of LEGAL authority and we need to strike these idiotic laws down and bring these law breaking public officials to justice.
I will grant that the US Constitution gives no such authority. But I do not think the state of New York derives any authority at all from it, since it is an enumeration of Federal powers only. As far as I know there might be something in New York's constitution that the law may violate, and I hope there is. As for the 14th Amendment's equal protection clause, I can't see that it applies.
I guess I should justify why I don’t think the 14th Amendment applies...let me put it this way, it would apply if former slaves were denied the 32 ounces and whites were not.