Freedom of speech is meant to preserve democracy domestically, not be a free for all to aid enemies for profit. Any sane state, including free democracies, would prohibit residents from teaching rogue enemy nations how to avoid sanctions.
I do not think that this is a widely held view. Regarding the US constitution for example, Part of Bernstein v. United States was the complaint that DJB was not able to legally talk to or teach about cryptography to cryptographers and students that are not US citizens. As for the "freedom of speech" as a general concept, I think that it is more of an individualist than a collectivist principle. It does not refer to countries or groups by itself, it is the right for entities to speak freely.