This is Aquinas's ST 1-2.96.4, as translated by me. All the standard caveats apply; as usual I've preferred to stick as close to the text as I think I can get away with. The Dominican Fathers translation is here; Freddoso's translation is here (PDF). The Latin is here.
To the fourth we proceed thus.
It seems that human law does not impose necessity on a man in the forum of conscience. For an inferior power is not able to impose law in the court (iudicio) of a superior power. But the power of man, which makes human law, is inferior to divine power. Therefore human law is not able to impose law in the divine court, which is the court of conscience.
Further, the court of conscience mostly depends on divine mandate. But sometimes divine mandates are voided by human laws; as according to Matthew XV, "The mandate of God you have made ineffective (irritum) through your traditions." Therefore human law does not impose necessity on a man with regard to conscience.
Further, human laws frequently throw calumny and injury on a man; as according to Isaiah X, "Woe to those who introduce iniquitous laws, and in writing write injustices, such that they oppress the poor in court, and do violence (vim) to the cause of the humble of my people." But it is licit for anyone to avoid oppression and violence. Therefore human laws do not impose necessity on a man with regard to conscience.
But against this is what is said in I Peter II, "This is gracious, if according to conscience he endures sorrows, suffering (patiens) injustice."
I reply that it must be said that human laws are either just or unjust.
(1) If they be just, they have obligating force in the forum of conscience from the eternal law, from which they derive; according to Proverbs VIII, "By my kings reign and lawgivers decree justice." Now laws are said to be justice both from the end, that is, when they are ordered to common good; and from the source (ex auctore), that is, when the law made does not exceed the power of the maker; and from the form, that is, when according to a proportional equality it imposes burdens ordered to common good. For, as one man is part of the multitude, so all that this same man is and all that he has is of the multitude, just as everything that a part is, is of the whole. Thus nature inflicts some harm on the part so as to save the whole. And according to this, laws like this, inflicting burdens proportionably, are just, and obligate in the forum of conscience, and are legal laws (leges legales).
(2) But laws are unjust in two ways. In one way, through an opposition (per contrarietatem) to human good, from opposition (e contrario) to the aforesaid things, either from the end, as when some magistrate (praesidens) imposes on the subjects burdensome laws not pertaining to common utility (ad utilitatem communem), but rather to cupidity and vainglory; or else from the source, as when someone makes law beyond the power committed to him; or else from the form, as when unequal burdens are dispensed to the multitude, even if ordered to the common good. And in these ways they are violence rather than laws, because, as Augustine says, in the book of Lib. Arb., what is not just seems not to be a law. Wherefore such laws do not obligate in the forum of conscience, unless perhaps with regard to the vice of scandal or tumult (turbationem), in which case a man ought even to cede his right, according to Matthew V: "If a man makes you walk a mile, go with him another two; if a man takes your coat, give him your cloak as well."
In another way, laws are able to be unjust by opposition to divine good, as when the laws of tyrants inculcate idolatry, or anything else that is contrary to divine law. And such laws in no way should be observed, because, as Acts V says, "We ought to obey God rather than man."
To the first, therefore, it must be said that, as the apostle says in Romans XIII, all human power is from God, and therefore who resists that power, in that which pertains to the order of that power, resists the order of God. And according to this he is made guilty with regard to conscience.
To the second it must be said that this reasoning works (ratio illa procedit) for human laws that are contrary to the mandate of God. And to this the order of power does not extend. Therefore in such human laws is nothing to be obeyed.
To the third it must be said that this reasoning works (ratio illa procedit) for laws that that introduce an unjust burden (gravamen) on the subjects, to which the order of power conceded by God does not extend. Therefore neither in such things is a man obliged to obey the law, if it is possible to disobey without scandal or inflicting a greater harm.
NOTE ADDED LATER: It occurs to me that it might be useful to point out that by 'scandal' Thomas means something very specific, namely, the vice of talking or acting in such a way as to cause the spiritual downfall of another, i.e., acting in a manner that leads another person to sin. It is the vice opposed to beneficence. It's a bit harder to say what exactly he has in mind by turbatio, which is usually translated 'disturbance'. It's possible that this is a hendiadys, and this is suggested by some of the passages in which he mentions it along with scandal (ST 2-2.69.4 is a good example). However, I find that he later (ST 2-2.3.2) uses the term along with that for scandal in the context of 1 Corinthians 10:32, which has to do with not giving offense. Elsewhere he notes that there are overriding reasons why prelates should be able to punish people regardless of whether they are disturbed. I've translated the word as 'tumult' just because (1) it is vague enough and (2) sounds serious enough to convey what Aquinas probably had in mind. He clearly doesn't mean just any sort of disturbance or unrest. It's noteworthy that turbatio is the word Aquinas uses when he discusses the problem of how Christ's death caused a disturbance, turbatio, in society, namely, by King Herod slaughtering hundreds of innocent children. I'm pretty sure that, if the phrase 'scandal or disturbance' is not a hendiadys, it's things on this order that Thomas has in mind when he uses the term.