How about:
(defun my-insert-color-hex ()
"Select a color and insert its hexadecimal format."
(interactive "*")
(let ((buf (current-buffer)))
(list-colors-display
nil nil `(lambda (name)
(interactive)
(quit-window)
(with-current-buffer ,buf
(insert (apply 'color-rgb-to-hex
(color-name-to-rgb name))))))))