You need to state which story format (name and full version number) you are using, as answers can be different for each one.
Your question title includes the <<set>> macro from SugarCube but your example contains Harlowe syntax macros, based on your example I am going to assume you are using Harlowe v1.2.4 as your story format.
Harlowe has a (text-colour:) macro which can be used to either directly colour text or it's return value can be assigned to a story variable while can be used to colour text instead.
(set: $colour to (text-colour: "yellow"))
$colour[This text should be yellow]
(set: $colour to (text-colour: "green"))
$colour[This text should be green]
As explained in the macro's documentation you need to pass a valid colour value to the macro.