These already exist, they’re called CNS stimulants.
Simplifying a lot here, but people with ADHD are statistically more likely to exhibit addictive behaviours because the addiction provides dopamine that their brain otherwise has trouble getting. Treatment with prescribed CNS stimulants is very effective at preventing those behaviours because the brain no longer has to engage in the addictive behaviours to obtain sufficient dopamine.
Here’s one study where patients reported significantly lower rates of alcohol and drug use over at least a one year period.