I don't know if that will work, and I don't know what the AI would do if the lord is unable to exit a certain area. The script might look like this: if you defeat a lord and certain conditions are met, the lord will be placed in a disconnected interior map and will never leave. That being said, the only way to do it is to make some kind of script, which I don't even know is possible.
However, they also won't be able to lead armies, become vassals or hold fiefs. If you remove them from this section, they'll be killable and treated as regular troops. Lords are treated as immortals, and will always only be captured or escape when you defeat them, and are even located in a different section of the mod structure, just so the game will recognize which units will never die. In the base game engine that isn't possible.