The answer will depend a lot of the locale (laws) and, above all, what sectors are affectd by the boycott.
Discriminating between government and non-government entities could easily go against local trade laws. And of course, even if it is legal, often it will be easily circumvented by using private strawmen.
A second issue is that such a boycott could be illegal if the service/good is needed for essential/strategic services, which are way more protected. For example maybe Oracle could stop supporting the databases used for pet registration, but would not be allowed to stop supporting the databases used for emergency centers/police/public hospitals. And in case the law does not directly address it, emergency legislation would probably be issued1.
And then there is the possible issue of breach of contract, as any sane IT organization will try to protect its operation by ensuring that its suppliers are bound by a contract to ensure that the service is provided in the conditions needed.
1And before anyone asks "Why doesn't the government just protect the pet registration system the same way?", there are usually Supreme Courts and Parliament that can review (even if at a later date) the emergency legislation and object to the abuse of the formula.