It's possible to define or modify a variable from a script, use the task.setvariable logging command.
Sets a variable in the variable service of taskcontext. The first
  task can set a variable, and following tasks are able to use the
  variable. The variable is exposed to the following tasks as an
  environment variable.
When issecret is set to true, the value of the variable will be saved
  as secret and masked out from log. Secret variables are not passed
  into tasks as environment variables and must be passed as inputs.
Examples: 
##vso[task.setvariable variable=testvar;]testvalue
##vso[task.setvariable variable=testvar;issecret=true;]testvalue
More details please refer Define and modify your variables in a script
You can run a script on windows agent using either a Batch script task or PowerShell script task. You just need to read the specific file in source control, download it in the workspace on the build agent. Then read the file, a way using powershell for your reference: Read file line by line in PowerShell