Typically moral questions need to be referred to some moral framework, because, while there is wide overlap on moral intuitions, there is no one universally endorsed set of moral standards, and there are moral questions where different moral frameworks (or set of core commitments) arrive at widely divergent answers.
In this case, however, your question seems to be more oriented around whether any moral framework can establish arbitrary rules, and if those rules then do have actual moral force. There are two ways to approach this. One, we can note, that, in practice, very few moral laws are actually completely arbitrary, they may just have a significance that is unclear. For example, many of the ancient Jewish dietary and cultural rules seem arbitrary out of context, but when considered as a group, they have a collective impact as a way to establish a unified group identity and self image. Two, there's arguably value in following a moral code, even if the individual moral rules are arbitrary --it provides some structure to life, and a point of connection between people.
If you believe, however (as most of us do, at some fundamental level) that there are objective, universal moral absolutes, then a moral code that promotes objectively immoral behavior would have to be judged as itself immoral (from some outside moral standpoint). Proscribing what amounts to a death sentence for a minor transgression might well fall in this category. You could also have a self-defeating moral code --for instance one that both enforced and prohibited the wearing of red. That code would arguably itself be immoral on the grounds that it damages the entire institution of morality.