Its absolutely constitutional. Electors are chosen by each state in a manner determined by the legislature of that state. Where this scheme probably fails is if a state reneges on this scheme. The other states involved would have no legal remedy to force the rogue state to follow it.
Imagine if Baton Rouge goes rogue!
So you might find the Democrat nominee carrying Colorado but the Democrat electors being pledged to vote for Trump if he has more popular votes. Of course if the electoral vote margin is close, they will renege and vote for the Democrat. Probably they will do so in any case. They can always count on the gullibility of the voters.