What are the moral and legal consequences of "not thanking" government for not providing viable grants? Recently, on various social platforms, an image containing an unusual acknowledgement in some paper have been circulating. This is about the following paper RF fingerprint measurements for the identification of devices
in wireless communication networks based on feature
reduction and subspace transformation by J.L. Padilla, P. Padilla, J.F. Valenzuela-Valdés, J. Ramírez, J.M. Górriz, Measurement 58 (2014) 468–475, which has the following Acknowledgement:


 "This work has been carried out despite the economical
difficulties of the authors’ country. The authors want to
overall remark the clear contribution of the Spanish Government
in destroying the R&D horizon of Spain and the
future of a complete generation." 


Another interesting example provided by @Federico Poloni is the paper  Rumour spreading and graph conductance  by Flavio Chierichetti, Silvio Lattanzi, Alessandro Panconesi, 
where the authors write:


"Unacknowledgements

This work is ostensibly supported by the the Italian
Ministry of University and Research under the FIRB
program, project RBIN047MH9-000. The Ministry
however has not paid its dues and it is not known
whether it will ever do."


Another paper recently published offers a sad story in the acknowledgements,(I will just put the reference here "On functional representations of the conformal algebra", by Oliver J. Rosten, Eur. Phys. J. C (2017) 77:477
DOI 10.1140/epjc/s10052-017-5049-5)

In "A New Horned Dinosaur Reveals Convergent Evolution in Cranial Ornamentation in Ceratopsidae by Caleb M. Brown, Donald M. Henderson, Current Biology, Vol. 25, Issue 12, R494–R496
DOI http://dx.doi.org/10.1016/j.cub.2015.04.041, there is a proposal:


 Funding for this research was provided by the Royal Tyrrell Museum of Palaeontology and the Royal Tyrrell Museum Cooperating Society.
C.M.B. would specifically like to highlight the ongoing and unwavering support
of Lorna O’Brien. Lorna, will you marry me?


In "Rotational splittings with CoRoT, expected number of detections and measurement accuracy" by M. Goupil, et al., Caleb M. Brown, Donald M. Henderson, Current Biology, Vol. 25, Issue 12, R494–R496
, where is the following text:


 We do not gratefully thank T. Appourchaux for his useless and very mean comments


There are also more:
Van Valen (1973). A new Evolutionary Law. Evolutionary Theory 1:1-30.


I thank the National Science Foundation for regularly rejecting my (honest) grant applications for work on real organisms (cf. Szent-Gyorgyi, 1972), thus forcing me into theoretical work


Although I fully empathize with the authors view, I wonder about the legal and moral consequences of considering adding of such an acknowledgement in one's 
future career. 

P.S. If you have discovered a similar story in a different paper that it is not listed here, please feel free to add it. Thank you!
Academic publications are in general not the right place for politics. And especially not for personal vendettas. Doing the latter is deeply unprofessional (though I'd wager some great scientists did this as well).

However, government officials and institutions are public not private actors and as such are in democratic societies put to more scrutiny (in their official function) than private actors. Addressing StrongBad's concern of people starting to "not thank" your publisher,supervisor etc, this is definitely a difference I would see.

For contemporary major moral discussions - like "should we start a genocide or not" - I'd say the bigger moral question can trump the professionality aspect by far though.

Now that we covered the general and extreme cases, back to the dirty middle ground.
Criticizing a political official or institution who acts in a researchers opinion damaging to science (or to society by his stance to science) or who likes to claim supporting science while his acts paint a different picture, I'd consider a borderline case. 
It's a public body and it affects science, thus to some degree relevant for the audience and the author. Especially when there is no official body properly representing the scientific community in that country, such a statement may be a reasonable approach to inform the public about the opinion of the broader scientific community. But it comes off as petty easily if it's just general critic for a particular agenda that doesn't suit your own ideas or if it seems you are just angry because you in particular didn't get funding while others did. 

So legally, it's irrelevant in most countries, as long as you don't include libel or insult (depending on country). It is, in general, unprofessional, but sometimes the bigger issue at stake may still validate it morally.

It's basically your individual choice to break with the professionality in order to further your political agenda. It may hinder your scientific career and cost you reputation, while helping your agenda. However, if you're unlucky it may also have the opposite effect and along with your own reputation loss, cost your political movement reputation with conservative people/voters/observers. In the end, it is very context depending - who are you criticizing, for what reasons, who is your audience and how receptive may they be to your message. Same for your career. If your scientific peers agree with your opinion they may ignore your breach with professionality - but does that also hold for international colleagues who may have no idea what you are ranting about?