XY problem.

If you're controlling a 12V BLDC fan, **get one that has PWM control built-in** (that is, a 4-wire fan.) Unlike brush motors, BLDC motors don't tolerate the full range of lowered voltages, as they use a motor control IC to commutate the motor phases. (In my experience, the dropout voltage on a 12V BLDC fan is about 6-7V.) In contrast, with a 4-wire fan you only need to supply the PWM, and it can vary between 0 and 100%. Much, much easier and cheaper than using a controlled DC supply.

If you're determined to manipulate the DC voltage, read on.

First off, to be safer, use the low side resistor for this. Then as you decrease the resistor value, the output voltage increases. Also, you don't affect the feed-forward cap as much.

Second, how best to use PWM to control DC-DC? Typically, you will modulate the feedback node with an injected current. With a PWM control, such a circuit looks something like this ([simulate it here][1]):

[![enter image description here][2]][2]

The PWM will create a net current in or out of the feedback node. Current out of the feedback node will raise the voltage; current in will lower the voltage. 

As shown, there's a voltage divider on the PWM which scales the PWM to the feedback voltage (1.2V). 100% duty cycle will be sourcing no current, resulting in the minimum output voltage (2.4V). Lower PWM duty cycles will sink current and raise the voltage, up to a max of 14.2V at 0% duty.

You can modify this behavior by changing the PWM divider resistor values, such that your output minimum voltage could even include 0V (make the divider's 3.8k to 3k for example, which yields a range from 0V to a bit below 15V.)

(Note: LM2596 Vref (feedback) voltage is 1.23V. Adjust accordingly.)

Could you use a FET modulated as a resistor? Sure, with some work. You could use a matched pair, and make a *current mirror* out of them with the reference current manipulated by PWM.

But to be honest, I've not seen this done since it's possible to do the same thing with just passives as I've shown above.

A more sophisticated approach is to use a pair of FETs as a *charge pump*. In this case you would control the duty cycle of each FET separately, to achieve a net current into or out of the feedback node. This can result in less noise on the output.

Finally, there is a better way. Maxim Integrated makes a line of current sink/souce DACs that are I2C controlled. They're designed for exactly this job. More here: https://www.analog.com/en/products/ds4422.html Then you avoid all the noise issues associated with PWM.

BONUS: If you need only a couple of specific voltages, I offer this suggestion: use several low-side resistors in series, and use FETs to selectively ground them. More here: https://electronics.stackexchange.com/questions/449666/changing-output-voltage-of-a-buck-converter-by-electronically-swapping-the-feedb/449732#449732

  [1]: https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCDsB0AcYCYCsBTAtJcAGaCtYUkgGYtYEA2ATisySxCRABZjH0wwAoAQxFObgEsFviEiq4JmjBMw%20BQzDQwNWLSRJhxWGQrhc2RVwBK-LIM4IQha1ZAMGzJYccPoSLgA9wFS7JssfU4RQQRBADUAJxQAMy4Ad1ElYRZmEUQRLES0jNTmdN9HLijcorK8LKN8EoqyCshrJWMkgpFK8zD67KSBQJE%20sAKHLgBzBus2m1gq7NK%20jvCGDubsgGMbZ37N5aR9R2hFLAhlRCH04mZVXVhiTBx8bnGlmz2dm0aHEdKwSH0O37BChuHQ1MyA8qZcqCJjOBSML4HS5cYgUUKFKHpFKzWoQ5DBP7bFI1cZ4t54z7FJJ4%20ovFZcAD24EEfi%20zhoCIeiCYSkZUhArKcWA5eAMwXAKIyggAYhAeUYQDIQAARACuABcAJ4AHQAzgBhTVrAA2KC4QA
  [2]: https://i.sstatic.net/nMJ4Wm.png