M.G.L. c. 46 s 1 prohibits the recording of a father's information in the birth record of a child of unwed parents "except as provided in section 2 of chapter 209C where paternity has been acknowledged or adjudicated under the laws of the commonwealth or under the law of any other jurisdiction." This does not, however, restrict the right of the Mother to use the Father's surname, only restricts her ability to list him as the Father without his agreement.
There may be administrative limitations such as limiting the full name to 40 characters for recording in the Massachusetts electronic data system (as reported in a law review article, Naming Baby: The Constitutional Dimensions of Parental Naming Rights). It is also likely that administrative officials might refuse to record names that contain obscenities or ideograms. The above referenced law review article discusses the constitutionality of such restrictions.
In the event parents disagree about the name of a child, the court may also become involved. MassLegalServices.org provides information about Petitions for Name Change including a summary of what happens when parents disagree. The short version is that the court will decide what name is in the child's bester interest taking into account factors such as the length of time the child has used a previous name, the age of the child, and any potential difficulties or embarrassment a current or proposed name may present.