Should one be required to follow an immoral law? That is the law is blatantly discriminating such as Hitler did to Jews in Germany. Should one be imprisoned just because they violated the law and the law is unjustifiable at the same time.
Before answering should, we should look at can a person be punished for disobeying a law they find immoral. The answer is (surprisingly) not always yes.
Many states have provisions in their laws that allow people special dispensations for religious observance, for instance. Additionally, when Australia briefly experimented with conscription during the Vietnam War, it still respected the rights of Conscientious Objectors.
Why? Well in the first case, laws are there for the protection of the State and its citizens, not as an alternate to religious belief. That's not a carte blanche exemption; if your religion allows human sacrifice the state can still call that murder. If your religion allows you to beat other family members, the state can still call that assault. Ultimately, your law-defying practice cannot exempt you from impacting others and the boundary condition for that line will be set by the courts on a case by case basis.
This in turn demonstrates the importance of strong separation of Church and State. It is the state's job to protect and care for the populace; it is the church's role to protect and care for the individual (or at least their soul). When you get right down to it, they're two different things and will sometimes be at odds with each other.
A thought experiment; let's say that your country has (for some reason irrelevant to this discussion) a real problem with genetic diversity. The wrong people have been marrying and that means that there are some problem recessive genes causing massive medical issues for the country and it has been decided by scientists that in 3 generations (unless something is done) the population of the country will be simply unviable. Birth rates are already at an all time low and the nation is in serious trouble.
So; the country quickly enacts a law stating that from here on in, EVERY woman of child bearing age will have a minimum of three children, each to a different father. It's now illegal to have more than one child to the same father, no matter how many children you have after that.
Legally, it's a responsible and measured action to protect the state. Morally, it's state-forced adultery.
Can people be punished for disobeying this law? Most certainly, and there's a compelling argument that the state is obliged to do so for its own protection. Should people be punished for disobeying this law? Not necessarily. Just like with national service, if you have a legitimate moral objection to a specific act (killing or adultery respectively) then it doesn't make sense for the state to take action against you. In the case of national service, the army probably doesn't want pacifists in the first place. In the case of cross-breeding, making an example of people with strong moral objections will only foment revolt.
We rely on the state for mutual protection and services. The state builds our roads, provides us with police to protect us against malcontents, and in most cases provides a welfare safety net and health services. It supplies a military whose role it is to defend us from our enemies and creates laws that best meet the needs of the citizenry to make the country prosperous and safe. The deal we make with our country is that we will support it in those endeavours by agreeing to be bound to the laws it makes.
By comparison, our choice of religion (and by extension our moral code) is personal, and the decision to obey a law in violation to our morals (or hold our own morals inviolate in defiance of the state) is also personal. An enlightened state will realise this and provide some safeguards that allow a small measure of flexibility where this can be an issue.
In theocratic countries (countries where church and state are the same thing) one may argue that this issue doesn't actually arise, but I'd argue that you cannot serve two masters; either you will be great at supporting the state, at the potential expense of the individual, or vice versa, or some mix in between.
Ultimately, the biggest problem with allowing people to violate the law on grounds of their moral code is that everyone has a unique interpretation of their own morals. What would be the point of laws at all if every law could be safely ignored by virtue of a moral code? In such a world, religions are effectively in charge of things and their agenda cannot be to preserve the state which is the true role of government.
That said, the option of civil disobedience is a personal choice, and one that should not be taken lightly. If one goes down that path, it should be because the needs of the state have been taken properly into account against the personal impact and still be seen as wanting. In the vast majority of circumstances, that won't be the case.
Breaking it up this way and facing law with morality is not helpful. Whether you consider two or more sources of 'should' or just one doesn't matter in the end. The resulting amalgam comes together and is inconsistent. It just is. People who try to adopt a single standard that combines or layers religion, law, culture and personal morality still have this problem. Religions, laws, cultural expectations and moral codes are in-and-of-themselves almost always inconsistent.
Conflict will happen both within and between different sources of obligations. When it does, you have a real decision to make, and adding more rules will give you no help making it. You have to decide to risk one kind punishment or another: the state or the federal sentence, psychological conflict or imprisonment, social ostracism or heterodoxy, immorality or the need to hide from the law.
Perhaps one of these structures will make space for the other: religious rights are a constitutional limitation on some countries' laws, remorse and extenuating circumstances clauses are built into other laws, mercy is often an aspect of moral codes, etc. If they do cooperate, that mitigates the risk. But often they will not.
In the end, this is not about what code wins over what other code. It is about the fact that 'should' modalities are not naturally consistent in a way that other modes are. You can ultimately decide what you want, even if you are torn. Science can remove conflicts between facts over time. But when it comes to obligations, conflict seems to be constant and necessary.