But yes Apple as a corporation can be punished financially if they refuse, if you hold that corporations don't have speech rights.
Your point is not consistent.
If code is speech, and compelling the development and signing of code is compelled speech and thus prohibited, then it shouldn't matter whether the legal entity charged with the development and signing of that code is a company or an individual. It's wrong to compel an individual developer to develop and sign a backdoored version of a program they personally wrote and personally hold the signing keys for, and therefore it's wrong to compel a company to develop and sign a backdoored version of a program they collectively wrote and collectively hold the signing keys for.
It's like the government saying "Look, individually you Catholics are fine. Believe what you want. But as a group we're going to need your church to collectively renounce the Pope."
They just might. The problem is that there will always be people who will do it for a small amount of money or because of a misplaced sense of patriotism.
There are substantial arguments that need making about whether code is speech, whether compelled production of code is compelled speech, whether compelled signing of code is compelled speech[1], and so on. But I don't see any reason why those arguments should have different answers when applied to the group of people comprising a corporation than when applied to individual people.
[1] For that one, see Wooley v. Maynard, which even in the dissent said 'For First Amendment principles to be implicated, the State must place the citizen in the position of either apparently or actually "asserting as true" the message'; that sure sounds like the function of a digital signature to me.