IANALI am not a lawyer, nor am I an employee, so obviously, take an official answer over mine
I was also saying would Stack Exchange try to seek that code is speech in courts?
So far, we've never seen Stack Exchange be particularly activist over such matters. Stack Exchange runs a business of hosted Q&A access (via teams and enterprise) or selling instances of such things for various levels of self hosting. Such a ban is unlikely to be contested, simply because it doesn't make much sense to.
Or would it take the legal safety of the GitHub approach which ended up deleting the accounts of foreign developers immediately without waiting to be asked to do so ?
I've not seen this happen before. That said, the developer of Silk Road has an account, and if I understand correctly - Stack Exchange was asked for information about this
Assuming things haven't changed since they said
We comply with any legally enforceable requests for information from law enforcement agencies.
It seems quite reasonable to assume that
The staff of the company, even those involved directly in the community are not going to be aware of everything the US government does, or everything that goes on over several hundred communities
Its going to take a specific, legally enforceable request to do something. Its worth taking a look at how DMCA takedowns are handled.
Any such actions would need to keep the local mods filled in - and where a specific topic was blocklisted on meta due to company policy, in general it was handled by the community team. Meta might be special, but 'legal' isn't something mods handle, and day to day moderation on a specific site is a 'special' case for the community team, so it'd likely need mods to refer such questions to a community team member or legal.
Which is a lot of words for "The government organisation would need to ask properly, formally and legally, and we'll have to figure out what to do"
I'd note that I've never heard of accounts in good standing being deleted for these reasons and in general, I feel like an account deletion would be the wrong thing to do.