In some cases, it may be appropriate for judges to pretend that statutes say things slightly different from what's actually in the text, if what the text actually says would be unconstitutional or meaningless, but it's fairly clear (possibly from legislative history) what the statute was supposed to say. This occurs most often in cases where some sections of the law get renumbered without properly updating other sections that make reference to them. It has long been considered perfectly proper for judges to apply minor tweaks to a statute in cases where the text of the statute was clearly erroneous (e.g. section 123.4 of a statute says "Except as described in 123.6, various rules apply"; section 123.6 has nothing to do with the situations in question, and section 123.7 begins, "Exceptions to 123.4 include..."); it would not be judicial overreach to interpret section 123.4 as referring to section 123.7.
The bigger problem here is that the Court has dropped any pretense that legitimate taxes must at least claim to be intended to raise revenue, rather than punish behavior. Ironically, Roberts threw the concept of "legislative intent" completely out the window. The people who wrote the legislation used the term "penalty" to refer to the monies people would have to pay if they didn't buy acceptable insurance. It's pretty clear they intended that the fines were intended to be considered punitive. In order to justify his decision, Roberts is declaring that he knows better than the legislature what they meant when they wrote the legislation. Judicial activism in the extreme.
Thanks for those explanations. They make the situation a lot clearer.