I came up with a seemingly similar solution.
The three would decide to line up in any order. We would label the person in the back as the 3rd, the middle 2nd, and the front 1st.
Assuming you can change the writing format when writing pass, you could write it in uppercase / capitalize the P if you see a matching pair or in lowercase if there's a diversity. Otherwise you just have to find a subtle way of communicating like pausing. Or does this still violate the "no communicating in any way" rule? You won't talk with each other, make noises, do hand gestures, face expressions but make a pause (like for say 5 seconds).
The 3rd person would take his move based on the two hats he is seeing, if a diversity is present he would write pass immediately, if a pair of color exists instead he would make a pause before writing down pass. By 3rd's action the 2nd person would be aware if a diversity exists or not, he would just say the opposite color or the same color of 1st' hat in order to win.