Am I getting closer? Program a DAC like a TLC5615CP which provides an analog voltage output, then use it to drive either a transistor with a Vce over 40 volts, or a transconductance amplifier like a NE5517ANG which translates its input voltage to an output current. Then use this intermediate device to control the LM317.
Each choice is a compromise: The transistor is probably not linear enough to directly relate the digital input to the current, so I may have to do a table lookup on the software side to accurately select the output voltage. The TC amplifier says the maximum buffer output voltage is 10 volts, which is not enough, so I may still need to buffer it somehow.