Thank you for sharing the use case.
The original ask was to decide during runtime whether the forEach runs sequentially or in parallel.
Ideally this would be done by placing the forEach inside an IfCondition activity or Switch activity.
However, at the present time, placing the forEach inside IfCondition activity or inside Switch activity is prohibited.
I do have a way to work-around this limitiation. I will replace the IfCondition activity with a conditional of my own making. See pictures below.
Expression in second setVariable (boolean): @if(equals(variables('isSequence'),true),true,'IamStringThatBreaksTypeError')
The key to this, is I intentionally cause the second setVariable activity to fail when isSequence is false. This way, when isSequence is true, we follow the success dependency to do the ForEach with the sequential flag. When isSequence is false, we follow the failure dependency to do the ForEach without the sequential flag. This may not be exactly the same as dynamically setting the flag, but it gets you the same result.
The skipped dependency keeps this intentional failure from causing the pipeline to report failure status.