Use a hex editor to switch sides, sell the palace, save the game, then use the hex editor to switch back.
But be careful, since if you do anything as the other player which causes the AI to "wake up", when you get back to your nicely planned original civ, you might find it has gone thru a revolution, and your units are all traversing the world with random "goto" commands. Can be a nightmare to clean up sometimes...
Here's how to do it from an old entry I got somewhere (probably this site, 10+ years ago, LOL). To do it from a hex editor, it's the 3rd double-byte from the beginning (i.e. ## ## 01 is the Romans, and ## ## 07 is the Mongols, etc), because of the 100-byte offset from "debug" to hex editor). Never did get that old save game editor to work, so i just stuck with the hex editor all these years.
--------------------------
Hack the Save File
There are three ways to hack the save game file: using debug, using a different hex editor, or using the saved game editor application. The exact steps for hacking the saved game file using debug are laid out on this page. If you have a favourite hex editor and you want to use that one instead, then simply follow the directions below for debug, but you may need to subtract 100 from the hex locations for them to work. For example, instead of changing byte 102 (for switching sides), you would have to use byte 002. If you want the easiest way, you can download the Civilization Saved Game Editor by clicking here. And now, on with how to use debug...
To hack a civilization save-file using debug (a hex editor that is built-in to MS DOS, so everyone has it

, go into DOS and find the directory of your civilization game.
Type:
debug civil#.sve (# = 0-7)
Example:
debug civil0.sve
You'll get a prompt that looks like this:
-
Press d and enter.
-d
A whole bunch of hex-garbage comes up on the screen.
When you're done editing the save file type w, enter, q and enter again.
-w
-q
Switch Sides
By typing: e 102 ## you can switch to a different civ, where ## =
00 (red-barbarians),
01 (white-Russians/Romans),
02 (green-Zulus/Babylonians),
03 (blue-Germans/French),
04 (yellow-Aztecs/Egyptians),
05 (lt Blue-Americans/Chinese),
06 (pink-English/Greeks),
07 (grey-Mongols/Indians).
This is very useful. Start the game. Build one city only and defend it well. Once you have good defense, save and quit. Now, Edit the save file to change the difficulty to something amazingly high (Find out how to do this here). Now, go back to the game and try to keep your city alivce for as long as possible. Right before it dies, save & quit and then put the difficulty back to whatever it was before and switch sides to one of these super-civs created by the ultimate computer players.
Example:
-e 102 02
(this changes the cililization you control to either the Zulus or the Babylonians. Only one will be in the game at a time, and that's the one you will switch to)