To a degree we already legislate morality. It would be impossible not to espically in the area's physical damage to another (including death), and theft. What makes a law viable is the legistlavtive ablity to quantify it and judicial enforcement of it. What I mean by legislative quantification is that a penalty needs be able to be assigned to it in such a way that a set standard can be imposed in reaction to the set fractions action. In regards to judicial enforcement is has to one that can be proven to a non-witnessing party and qualified as a deed that requires a sanction.
Communial living requires a communial morality that might differ from indidivduals morality but in a utilitarian sense is accomodating to a majority thus making is legistative in nature.
A non-prior conscenses on many moral issues creates a heavier bias to those invovled as the victim, aggressor (of said infraction) and judical adminstrators plus extra party involved as a set time limit is in place and a utilitarian application is not possible with limited partipants involved.
It also throws the agressor to the mercy of the other parties involved who many who will have a heavier emotional interest in an increased penatly of the aggressor. The aggressor having the further negative recourse of not having a prior say in the moral implication of the said behavior because was not presented to a judicial or legislative body beforehand.
The legistlation of morals on a community affords the benefit of collective reasoning less biased input as it is not dictated by circumstances presented before it.
The bigger and tougher questions may be what is quantifiable and with varying moralities combined in a set society what parameters can be used to index what is judgable, what is not, what is punishable and what is not.