Please don't include information about the version of Twine and the Story Format within the Title of your question, using the questions tags to provide this information (like you did) is the correct way to do that.
There are a number of ways using either TwineScript or Javascript you can achieve the result you require.
1. The following TwineScript uses the Javascript Object.keys() function to obtain generate an Array containing the names of each of pieces of clothing in your $clothes object, it then uses SugarCube's <Array>.shuffle() function to randomly sort that list. Looping through the list until the condition you're looking for is handled via a <<for>> macro combined with a <<if>> macro, and the <<for>> macro's child <<break>> macro is used to stop the looping once the condition is true.
<<set $clothes = {
shirt: "red",
pants: "blue",
socks: "red",
gloves: "green",
jacket: "yellow"
}>>
<<set _keys to Object.keys($clothes).shuffle()>>
<<for _i to 0; _i lt _keys.length; _i++>>
<<if $clothes[_keys[_i]] isnot "red">>
<<set $clothes[_keys[_i]] to "red">>
<<break>>
<</if>>
<</for>>
2. The follow (embedded) Javascript uses the same method as example 1 to obtain a random list of clothes names. It uses <Array>.some() function to loop through the list until the condition you're looking for is met then does the assignment you want and stops the looping.
<<set $clothes = {
shirt: "red",
pants: "blue",
socks: "red",
gloves: "green",
jacket: "yellow"
}>>
<<run Object.keys($clothes).shuffle().some(
function (element, index, array) {
console.log(`element: ${element}`);
var clothes = State.variables["clothes"];
if (clothes[element] != "red") {
clothes[element] = "red";
return true;
} else {
return false;
}
}
)>>
WARNING: The <Array>.some() function used above is a recent addition to Javascript and may not be supported in the web-browser being used by the Reader, if you are planing on using the above Javascript example then I strongly suggests you include the Polyfill included on the linked page within your story's Story Javascript area so that the above example will work for people using older web-browsers.