Use a Ternary operation (true ? "dothis" : "doother") inside of the echo:
echo '<li><a href="'.$category->getURL().'" style="text-decoration: none;'.($magentoCurrentUrl == $category->getURL() ? 'color:#fff;' : '').'" >'.$category->getName().'</a> </li>';
Ternary operation formula is basically:
echo "something: ".(true ? "dothis" : "doother")
which is the equiv of
if (true) { echo "dothis": } else { echo "doother"; }