Hi,
Here is a way that you make the LM317 current source adjustable. I used the LT1117 in the LTspice model for convenience.
Here is the original circuit:
Here is the modified circuit:
A voltage is developed across R3 which reduce the voltage needed across R1. The voltage across R3 depends on the current sink Q1, U2 and R4.
If the voltage on positive input is varied from 0-1V the current limit is reduced from 250mA towards zero
The 0-1V signal can come from a DAC or a PWM output, with suitable filtering.
Note: this circuit only works if the output voltage is greater than about 3V.
I have attached the LTspice models.
Jay_Diddy_B