AIUI, their constitution not only forbids removing the term limits, it specifies that any elected official who submits a bill to chage the constitution in that way be removed from office. If so, Zelaya had, in fact, violated their constitution and was properly removed from office.
If indeed that was what he'd done, then it could indeed have been legal to remove him from office. But that was not what he did, and the maneuvres against him were in fact manifestly illegal.
The coup was of course presented as legal by those who perpetrated it and now constitute the new de facto government (surprise surprise), but no other government anywhere has recognised the coup as a legal process. Not one. The coup d'etat has been condemned by the UN general assembly, the Organization of American States, the UNASUR, the US, the EU, etc, etc. Don't be fooled into thinking that the Honduran judicial system is some high-minded and independent branch of government. Honduras is a banana republic and has a thoroughly militarized and corrupt political system.
The new regime has tried (with some success, in the US at least) to put forward a cover story in which Mel Zelaya was unconstitutionally attempting to seek reelection and was impeached and removed legally. The tame MSM in Honduras has by and large gone along with the story (any media which haven't have been shut down by military force). But in fact Zelaya has always denied that he wanted to seek reelection. The right wing all say it was "common knowledge" he wanted to establish a "Chavista dictatorship", but this is just what they want to think: there's no actual evidence for it.
The poll which Zelaya attempted to hold was not an official referendum, in fact, but simply a public opinion poll with no official status. The constitution explicitly guarantees the right to hold such polls, by the way.
The poll merely asked Hondurans if they agreed that at the upcoming elections, there should be a "fourth ballot box" installed (i.e. alongside the 3 votes for president, congressional and municipal representatives), where voters could decide if there should be a national consitutional assembly to approve a new consitution. It did not ask what provisions any new constitution should contain. It certainly made no mention of term limits. In fact, even if the opinion poll had taken place, and if the result had favoured a "fourth ballot box", then Zelaya would've had his hands full ensuring that the ballot box actually was installed. If it were installed, and if the voters approved the idea of a constituent assembly, then there would have to have been further elections for the constituent assembly itself, then the assembly would've had to approve a new constitution. At that final point, the hypothetical assembly might hypothetically decide to remove some of the provisions which are "cast in stone" in the current constitution, and they might have run into legal trouble in so doing. But this is all "what-if" stuff ... Zelaya himself was a long way from breaking the constitution - he didn't even get a chance to do so.