Outside of Paul, νόμος is used - almost always - to refer to sacred writings in the Old Testament.
Matthew always uses νόμος to refer to sacred writings in the Old Testament.
In Matthew 5:17-18 (English | Greek | Cf. 7:12; 11:13), “law” is not only used in synonymous parallel with “Law or the Prophets,” but also the “not an iota, not a dot, will pass from the Law” indicates that “the Law” refers to the Old Testament, which was translated into Greek (the alphabet of which includes the letter “iota”). The “law” that is “read” includes Numbers 28:9-10 and 1 Chronicles 9:23 - according to Matthew 12:5 (English | Greek). In Matthew 23:23 (English | Greek), the “law” is said to include matters weightier than tithing, a command from Deuteronomy 14:22.
John always uses νόμος to refer to sacred writings in the Old Testament.
Actually, most of the occurrences of νόμος are used in connection with Old Testament quotations. John 10:34 (English | Greek) quotes Psalm 82:6 “written in your law...
"Pattern." So, when Jesus broke the egg, He broke the pattern of sin and death, the nomos of going down the drain - He nailed that to the tree. We don't have to go down the drain. We can choose life, choose the pattern of obedience and blessing, which is described in the Old Testament - that nomos.