Ok, here you go:
$dom = new DOMDocument('1.0', 'utf-8');
$dom->appendChild($dom->createElement('root'));
$dom->documentElement->appendChild(new DOMText('ירושלים'));
echo $dom->saveXml();
will work fine, because in this case, the document you constructed will retain the encoding specified as the second argument:
<?xml version="1.0" encoding="utf-8"?>
<root>ירושלים</root>
However, once you load XML into a Document that does not specify an encoding, you will lose anything you declared in the constructor, which means:
$dom = new DOMDocument('1.0', 'utf-8');
$dom->loadXml('<root/>'); // missing prolog
$dom->documentElement->appendChild(new DOMText('ירושלים'));
echo $dom->saveXml();
will not have an encoding of utf-8:
<?xml version="1.0"?>
<root>ירושלים</root>
So if you loadXML something, make sure it is
$dom = new DOMDocument();
$dom->loadXml('<?xml version="1.0" encoding="utf-8"?><root/>');
$dom->documentElement->appendChild(new DOMText('ירושלים'));
echo $dom->saveXml();
and it will work as expected.