If a law is morally wrong and you commit civil disobedience you have no moral obligation to be punished for opposing the immoral. That would be silly.
It may be that opposing the immoral law and accepting punishment has a better marketing aspect for convincing people of the immorality of the law, but doing that convincing might not be the purpose the person has, their purpose might just be opposing the immoral law.
It may be that opposing the immoral law and accepting punishment has a better marketing aspect for convincing people of the immorality of the law, but doing that convincing might not be the purpose the person has, their purpose might just be opposing the immoral law.