It's possible for a French victory in Mexico. Up until late 1865 they were militarily winning the war, and it was only when the US began running guns to the rebels and placing diplomatic pressure on France that the rebels began to have success in the field and Napoleon abandoned the project in 1866.
However, had a few things happened differently, a military victory in Mexico is possible.
Firstly, after the fall of Puebla in 1863, many generals (including Porifio Diaz, Jesus Ortega, and Ignacio Comonfort) who would later go on to greatly aid the Republican cause were captured and due to be exiled to France. Post surrender many escaped in the confusing series of defections and the transport of captured material to Veracruz. Had these three especially been moved overseas to a nice imprisonment then the military quality of the Republican armies in the field suffers greatly. And many Republicans, for want of leadership, might have simply cut deals with the Imperialists to just get ahead.
Secondly, had Juarez been killed anytime between 1862 and 1865, then the whole 'natural' leadership of the Republic collapses as their is no legitimate centralizing figure to rally behind. Sure resistance would continue, but it would be that headless and polarizing kind that sees the Republicans split apart over time. Worse there is no 'central authority' for the US to actually back in Mexico and send support to. Maximillian might become the de-facto head they are forced to recognize.
Thirdly, had a more clear command structure for the new Mexican Imperial Army been established, it might have prevented the chaos and inability which plagued it, allowing Maximillian to have a professional force loyal to him which would have been capable of defeating the rebels on their own.
If the Confederacy had survived somehow, the French task would have been easier since the Union suddenly has far bigger problems on its plate than a violation of the Monroe Doctrine.