The 0-12V spec requires a 50mV shunt and Op Amp and low RdsOn MOSFET to regulate any current you can afford to keep cool with a heatsink wasted on voltage drop.
If it were 2.5-12V then your LM317 method works for the range of current and heatsink also required.
When you use PWM with an RC filter and current shunt, you can cut all the losses and heatsink but need a MUCH bigger cap ($) rated for the RMS current you intend to deliver.
Then when you put a choke rated for the peak current in series with your PWM and regulate the current, now you have a a BUCK REGULATOR, which you can design using a registered email to www.ti.com's home page for a start, then use the datasheets to convert from CV to CC mode, where possible or other sources.
These are now readily available to consumers and Meanwell is a major supplier. It is also possible to modified universal laptop chargers to perform the same task over a limited range like 5-40V
New parts come out every day. THIS DOES WHAT YOU WANT.