I have checked ServerManagaer class and it gives a lot of functionality to work with IIS, it also contains methods to update values in applicationHost.config file, but I can’t fine any way to unlock sections there.
For example for that purpose appcmd.exe unlock config command is used. I need to do the same programmatically.
As already said you can run appcmd process. But just a hint that if you don’t console to popup you can redirect the output.
Here is the code from MSDN
More details see HERE