Look into the following MSDN article, it may be what you are looking for: https://msdn.microsoft.com/en-us/library/zhhddkxy.aspx
It is about using the aspnet_regiis
tool to encrypt sections of the config file, which will be decrypted by IIS/ASP.Net when it is requested by the application.