There is precedent that indicates otherwise, as this is a clear First Amendment violation.
Requiring commercial services to adhere to certain guidelines is constitutional, even though the Texas law is a bad one and I think a different court may have slapped down the law. Mandating speech (code is speech) is clearly not, especially for noncommercial projects.
I think the key would be getting the right person to explain how this would be like requiring all authors to include a certain sentence in their novel.
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.