The USG spent $6B on cloud computing in 2020. That number is increasing quickly. To say nothing of the massive quantities of non-OSS software that the government buys and incorporates into is own business-critical processes. And it's not just government licenses, but also anyone who interacts with the government. E.g., try interacting with any government agency without an Office 365 license.
You get really funny looks if you say that MSFT should have to give away Office 365 for free if the government is going to use it for anything.
But total USG spend on closed-source software has to be well into the 30B-50B range conservatively. For reference, the entire NSF budget is $10B.
The main reason for this is that there are many monied and powerful stakeholders who benefit from selling closed software to USG, whereas the academic publishers a tiny, often not even American-owned, and got super greedy and screwed their natural contingency (academics hate them as much as or more than anyone else).
Say I'm vulture capitalist Tom, and I pay a few gajillion dollars to developer Gupta to create a product for me. I would be understandably pissed if Gupta turned around and sold that same product to competitor vc Janet. She didn't pay for that dev work, I did.
And there's lots of useful software the government wants to buy that is closed source.
DARPA is probably the best-known route and funds a lot of academic and corporate research (including, for a while, me).
The DoD also has a bunch of other grant-making programs (Office of Naval Research, Congressionally-directed Medical Research Program, etc) and also labs that directly do research themselves. The Air Force has a big research center (AFRL) in Ohio; the army has one in Maryland (ARL), and the Navy has one in DC (NRL). There are loads of other sites as well: the army has a night vision research lab in New Jersey, for example, and the Navy has some marine mammal stuff on the West Coast.
A lot of this work--even the stuff done at DoD labs--winds up in open literature. By policy all of that is supposed to be publicly available, so you can browse it here https://discover.dtic.mil/products-services/.
Do you mean researchers employed by the military? Otherwise, basically half of every STEM professor I encountered had funding via some branch of the military.
But separately there is classified research that isn't published.
Take a new program like "FELIX" - simplifying ways of checking for bioengineered threats.
IARPA funds that, and the research funded through that program can be found here: https://scholar.google.com/scholar?hl=en&as_sdt=0%2C47&q=N66...
From the look of it they funded 9 companies and institutions to do the research and their poster presentations can be found at the bottom of [1].