I kind of doubt that most judges are going to agree with a "code is speech" argument. I think it's more likely that the courts view code as a mechanism, and so this is more like requiring cars to have airbags.
Though this does bring to fore the issue of enforcement. Nobody can stop you from building a custom car which has no airbags. Where enforcement happens is when you try to get it registered (thus making it legal to drive on public roads). That's when the government would stop you.
Curious how such enforcement would work for operating systems. We could all just mod our OS's to remove/bypass age verification. The government doesn't (currently, yet) have a legal nor physical mechanism to prevent this.