Apple is currently developing a legal response to the government's request that it create software to help the DOJ unlock an iPhone connected to the San Bernardino shooting. It seems part of its argument will, apparently, include defending code as a form of free speech. Bloomberg reports that an unnamed Apple executive has told it that the company will "argue in federal court that code should be protected as speech". It won't be the primary line of defence: That will be centred on an argument that the demand oversteps the powers granted to the government under the aged All Writs Act.
But a secondary defence will, if Bloomberg's source is accurate, lean on the First Amendment. Just as the government can't force someone to write a new story in its say so, Apple will argue it can't be forced to write code either.
It's not necessarily the best argument. Viewing all code as speech would make regulation of digital communication very complex, and courts will likely be careful about setting precedents.
But it won't the first time code has been argued to be free speech. Notably, Dan Bernstein, then a graduate students at University of California at Berkeley, successfully argued that his cryptography tools were freely publishable because source code should be protected as free speech.
But other cases since have failed to successfully assert that the First Amendment holds for code since and at any rate Apple's angle is rather different. We'll have to wait and see how it plays out in court.