You can achieve the requirement by either implementing a custom field or a custom token. I would tend to use the custom token
Custom Token
Below is the code snippet you can use to implement the custom token
public class CustomTokenReplacer : ExpandInitialFieldValueProcessor
{
private const string Token = "$customtoken";
public override void Process(ExpandInitialFieldValueArgs args)
{
Assert.ArgumentNotNull(args, "args");
// TODO: Add your own custom token replacement logic here...
}
}
Then you patch the newly created token via the config file
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<expandInitialFieldValue>
<processor type="YourNamespace, YourAssembly" patch:after="processor[@type='type=Sitecore.Pipelines.ExpandInitialFieldValue.ReplaceVariables, Sitecore.Kernel']"/>
</expandInitialFieldValue>
</pipelines>
</sitecore>
</configuration>
Note that in the datasource on your template, you should use the token you defined. Example: $customtoken
More information is available here.