This seems pretty simple as you can just set the properties of SPContentDatabase and you are good to go. However, this didn’t work atleast in my case.
I was creating a new farm from an existing farm due to project requirements, but I came across a situation wherein I was not able to remove the server from the farm using the SharePoint 2013 UI(server was already removed using the command or you can remove it by using configuration wizard on the server to be removed).
So, the error message which I was getting when I was trying to remove the server from the UI was “cacheHostInfo is null“.
Below is the solution to this problem which I followed and it worked.