The idea of a referendum being "illegal" may be counter-intuitive, but I don't think the situation is as simple as you suggest.
For example, secession (not to mention sedition or treason) is illegal in many jurisdictions, and is a natural thing for sovereign countries to want to prevent. It is also natural for the sovereign central government of a country to put limits on what a regional government can and cannot do, with the usual principle being that the regional government cannot do anything outside of the powers specifically given it by the central government (regardless of what powers the inhabitants of that region want).
You're right that "people" could "get together and conduct a poll on something", but if this was informally conducted it would be hard to prevent double voting, and not accidentally disenfranchising certain people, and there would be little recourse against these self-appointed pollsters stuffing their home-made ballot boxes.
At the same time, if a regional government spent money, or used people's personal information, for a purpose they were not legally permitted to, then those would potentially be crimes themselves, regardless of the issue of secession.
The questions worth debating are "How much autonomy should regions of sovereign countries be given?", and "If a region isn't legally given that much autonomy, what is most peaceful and just means for that region to attain it?"