It turns out that the code I'm using actually DOES work.
For some reasons kingdoms only show up in the encyclopedia after a save is loaded. This includes the player-created kingdom.
I've tested it in-game and the kingdom can be joined by the player, and seems to engage in diplomacy. (one of the kingdoms I made was at war by the time I was able to join it)