Can the MQTT ClientID be set dynamically?

Yes. See the full demo in the linked post: Dynamic MQTT LWT birth, Close & Will Property - #2 by Steve-Mcl it does that in the "connect with opts" inject