By Mexico, are we talking about the Empire of Mexico, or the Mexican Republic?
Because either way, it does nothing but make things worse.
Republic declares war, they will end up pissing off the USA in the post-Civil War era and will be wasting resources that could be better spent against the French.
Empire declares war, it won't change the USA's stance towards them: Lincoln had made it clear that he was sympathetic to the Republicans and distrusted the Mexican Empire. It would certainly push the USA's position from sympathetic to actively helping in the form of supplies.
There was the Hampton Roads Conference in 1865, where they discussed assisting Mexico against the French to help patch up North-South Relations, but the US is still not in much of a position to actually do so.
Regardless of which Mexico declares war on the US and Confederacy, it's ultimately meaningless and against their best interest.