Of uncertain etymology. Perhaps borrowed from Akkadian. cp. Akka. kutimmu ( = goldsmith), which derives from Sumerian kudim, of same meaning.
This word for gold appears a number of times in the Tanach. The Daat Mikra consistently suggests that there are opinions that ketem is the name of the land where the gold comes from. They point out that in Egyptian writing the term "nb-n-ktm" is found, meaning "gold of ketem", perhaps from Nubia.
Kaddari mentions both of the above theories as to the etymology of ketem, but then quotes Driver as saying that it is related to an Arabic word (I can't really make it out, but it looks like the parallel consonants of כתם) meaning "a plant used to die hair black", and connected to the word ketem meaning "stain, dirty" in Rabbinic Hebrew.
Klein does not connect the two forms of ketem - he relates the meaning of "stain" to the Akkadian katamu - "to cover". Others, however, do connect the two. Steinberg, for example, says both meanings - "gold" and "stain" - of ketem are connected to an earlier meaning of "to write". Etymologically, this is done through a connection between כתם and כתב. The one instance of כתם meaning "to stain" in the Tanach, appears in Yirmiyahu 2:22, where it says נִכְתָּם עֲוֹנֵךְ לְפָנַי - "your guilt is ingrained (stained) before me". Steinberg (and later Kaddari) compares this to Yirmiyahu 17:1 - חַטַּאת יְהוּדָה, כְּתוּבָה בְּעֵט בַּרְזֶל - "The guilt of Yehuda is inscribed with a stylus of iron".
As far as the connection between gold and writing, Steinberg claims that ketem refers to choice gold, and was so named because it was marked to indicate its value (see a similar opinion here). He makes a similar connection between the name of another type of gold - charutz חרוץ - and engrave חרץ (also חרט). From this meaning - writing - we can understand the name of the biblical poem michtam מכתם - which is the title of many of the chapters of Tehillim.
In this article, Moshe Zipor writes (my translation):
The noun ketem in the Tanach is synonymous with gold, particularly reddish-gold. From here we see that the verb נכתם (from Yirmiyahu 2:22) does not simply mean "stained", but "stained with the color red". In post-Biblical literature, ketem refers exclusively to the signs of niddah (menstruation) blood. (Other stains were called רבב).
Jastrow also defines ketem as "a dark red stain". As we have seen (and will continue to see) there are many words in Hebrew for "gold". I wonder if those who coined katom for "orange" did so due to the idea that ketem has a combination of gold (yellow) and red...
While Rosenthal does not give a slang association to katom, it became the color associated with those opposed to the 2005 Israeli withdrawal from Gaza, and even now, those on the Right are still called ketomim.