I wanted to accomplish same outcome as mentioned in the previous post: Web Package-based parameters. Since, the discussion was in 2014, I am wondering if Octopus has come up with some out of the box solution with recent versions. My Octopus version is 2018.6.14.
Create a transform file for each environment, e.g. app.dev.config and populate the transform elements with Octopus variables, e.g. <network xdt:Locator="XPath(/configuration/system.net/mailSettings/smtp/network)" xdt:Transform="SetAttributes(host)" host="#{SmtpServer}" />
Octopus will apply the transformations and then substitute all variables in the freshly-transformed file, as you require.
I hope this helps, please let me know if you have any further questions.