Exactly. Don't forget to make it a global variable so it persists and is available across macros. (You could use a Dictionary, but let's save that complexity for when you want to store lots of different flags!) You then set it with the 'shift' button and your main macro unsets it soon after the test.
Taking it up a level -- you could store the current timestamp in the variable, perhaps as unixtime. That way, when you press the second button you can include an "if the 'shift' button was pressed in the last n seconds" block.
Exact details will vary. If you never run the un-shifted version of your macro soon after the shifted version you won't need to reset the variable -- it will "time out" naturally. If you do need to to quickly run them one after the other use the first "set and unset" method so you don't still have a 'shift' when you don't want one.
If you are running the Keyboard Maestro Stream Deck plugin you could even make that 'shift' button a toggle, updating the button's icon to show whether 'shift' was on or not and have the behaviour of your macros change for as long (or short) a time as you need!