Three simple ways to voltage control the gain of an LM386.
1) Using a JFET as an AC coupled variable resistor from pin 1 to ground. This works reasonably well and has relatively low distortion.
Vishay AN105. FETS as voltage controlled resistors.
2) Using an NPN BJT in place of a JFET. This works but produces relatively high distortion.
3) Using an NPN BJT between pin 8 and in 1. This does not control the gain well. It produces high distortion and injects a high level of control voltage feedthrough into the output signal.
Note that in all cases the gain control range is only about 20dB (i.e. x10).
CTRL+R to run the simulation.