Even if it is not a war crime to do so, it is not a sensible military objective in most cases.
Usually, the goal of a military attack on a country is not to obliterate the country and salt the earth, but to secure a more favorable governing regime, or control of some part of the country, by replacing the top leadership of that country.
Ideally, in a case like Russia's initial goals in its invasion of the Ukraine, the goal is to install a friendly puppet regime in the militarily conquered country. But, in that scenario, the puppet regime would utilize, as much as feasible, the existing civil service of the existing regime to govern the country upon taking control.
If Russia, for example, destroyed the offices of the tax collection ministry or sub-ministry, the new regime taking power after its military success would have to incur lots of time and money rebuilding the country's tax collection system from scratch to put its own Russian friendly regime in place.
A military would only want to obliterate all government buildings if its goal were to render that country useless as an opponent, so that it could no longer attack it, without having any desire to actual rule or occupy or control the country attacked.
Also, wiping out all of the top leadership of a country isn't necessarily desirable. The cleanest way to win a war it to have the legitimate leaders of a country surrender and agree to your demands, as, for example, Japan did in World War II in 1945, and as the Confederacy did in the U.S. Civil War in 1865.
If the legitimate top leadership of a country is in place and still secure in its rule of its people, a single agreement from that leadership can achieve your military objectives swiftly with little further cost in blood or treasure, recognizing your credible threat to use further military force without actually requiring you to actually use that further military force to achieve your objectives.
But, if you have decapitated the ruling class of a country or at least undermined its authority beyond repair, then to achieve your objective and end the war you started on favorable terms, you need to enter into deals with every subcomponent of the country that has secure legitimate leadership possibly down to mayors and other local government officials, or worse yet, have to install a new system of government directly upon the people from scratch rebuilding their entire nation from the ground up in the face of a many headed hydra of opposition figures who must be subdued one by one.