I think there are longstanding principles of civil disobedience in which you accept the penalty for your lawbreaking. Such as, for example, the civil rights protestors who broke the law and willingly forced authorities to deal with enforcing unjust laws. I don't think one generally breaks the law without being willing to be held accountable for one's actions.
I think there are special circumstances when that sort of civil disobedience is not called for. For example, during the Holocaust if you were breaking the law by sheltering your Jewish neighbors you would not advertise the fact that you were doing so to the Gestapo in some form of public civil disobedience. As that would defeat the whole purpose of your action.