The capability "View author names" (mod/workshop:viewauthornames) is checked for each user when displaying published submissions. If the user has this permission, the names are displayed to them. Otherwise, the name is not displayed (unless the author puts it into the submission text, of course).
It is expected behaviour that a submission can be marked as to pe published during the grading evaluation phase only. Picking submissions to be published is considered as a part of the grading evaluation process.
Only the submission title, submission text and eventual submission attachments are published (and again there is a capability "View published submissions" required to see them). The assessments are available only to the author of assessed submission (and to those with the capability "View all assessments", such as teacher by default).
Students have no way to opt-out, teacher decides what gets published. It is expected that teachers communicate this with students in advance.