Bottom line, without registering the gun as a short barreled shotgun, the legal minimum is 18".
The entire gun must be at least 26" long.
It's possible some states or local laws may differ.
If shortening a shotgun barrel, keep it at least 18 1/2" long so as to provide yourself a 1/2" "safety" to prevent any question as to it's legality.
Shotgun barrels are measured by closing the action and inserting a rod or dowel down the barrel until it contacts the front of the bolt or breech face.
Mark the rod even with the muzzle, remove and measure the rod's length to the mark.