I'm not sure if this actually works (my xterm here isn't compiled with 256 color support!) but the xterm control sequence reference:
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
Look under "Operating System Controls"
P s = 4 ; c ; spec → Change Color Number c to the color specified by spec. This can be a name or RGB specification as per XParseColor. Any number of c name pairs may be given. The color numbers correspond to the ANSI colors 0-7, their bright versions 8-15, and if supported, the remainder of the 88-color or 256-color table.
OSC is \033], so try this out:
echo -n -e '\033]4;7;red\007'
should change color #7 to red if it works.