I have a text field which takes value from data collection. How color of text can be changed green for 'yes' and red for 'No'.

Yes you can do that easily with code, just depends on what type of field you are using in your dataset field for example.
https://www.wix.com/corvid/reference/$w.Style.html

I have done a basic sample here for radio buttons a while back here and you can view the code to start working on your own version.
https://givemeawhisky.wixsite.com/radiobuttonexample

Code used.

$w.onReady(function () {
});

export function button1_click(event) {
	if ($w('#radioGroup1').value === 'London') {
		$w('#correctMessage').show();
		$w('#wrongMessage').hide();
	} else {
	if ($w('#radioGroup1').value === 'Paris' || $w('#radioGroup1').value === 'New York') {
	    $w('#wrongMessage').show();
		$w('#correctMessage').hide();
	}
}
}

	export function button2_click(event) {
	if ($w('#radioGroup1').value === 'London') {
		$w("#button2").style.backgroundColor = "green";
		$w("#button2").style.color = "yellow";
		$w('#button2').label = "CORRECT!";
	} else {
	if ($w('#radioGroup1').value === 'Paris' || $w('#radioGroup1').value === 'New York') {
	    $w("#button2").style.backgroundColor = "red";
		$w("#button2").style.color = "yellow";
		$w('#button2').label = "WRONG!";
	}
	}
	}

export function button3_click(event) {
    $w('#radioGroup1').value = "";
    $w('#radioGroup1').resetValidityIndication();
	$w('#radioGroup2').value = "";
    $w('#radioGroup2').resetValidityIndication();
	$w("#button2").style.backgroundColor = "#384AD3";
	$w("#button2").style.color = "white";
	$w("#button8").style.backgroundColor = "#384AD3";
	$w("#button8").style.color = "white";
	$w('#button8').label = "WAIT!";
	$w('#correctMessage').hide();
	$w('#wrongMessage').hide();
	$w('#box2').hide();
	$w('#box1').hide();
	$w("#button5").enable();
}


export function button4_click(event) {
	if ($w('#radioGroup2').value === 'London') {
		$w("#button2").style.backgroundColor = "green";
		$w("#button2").style.color = "yellow";
		$w('#button2').label = "CORRECT!";
		$w("#button8").style.backgroundColor = "green";
		$w("#button8").style.color = "yellow";
		$w('#button8').label = "CORRECT!";
		$w('#box1').show();
		$w('#box2').hide();
		$w("#button5").disable();
	} else {
	if ($w('#radioGroup2').value === 'Paris' || $w('#radioGroup2').value === 'New York') {
	    $w("#button2").style.backgroundColor = "red";
		$w("#button2").style.color = "yellow";
		$w('#button2').label = "WRONG!";
		$w("#button8").style.backgroundColor = "red";
		$w("#button8").style.color = "yellow";
		$w('#button8').label = "WRONG!";
		$w('#box1').hide();
		$w('#box2').show();
        $w("#button5").enable();
	}
	}
	}

Actually it is not working with text field.

So if it is actually text that you want to change and not a text box or text input, then simply do that through html.
https://www.wix.com/corvid/reference/$w.Text.html

Your code should look something like this:

$w("#text1").html = `<p style = "color:red"> ${$w("#text1").text}</p>`;