How to calculate Op Amp's gain using Arduino's ADC
simulate this circuit &ndash; Schematic created using CircuitLab

You can try this circuit. Thanks to voltage follower your output signal doesnt has distortion when read output signals. Also there is voltage divider because output signal level can damage your arduino. Maximum output signal level is 12V and voltage divder can reduce this level to 4V. So your arduino doesnt damage from signal high signal level. Your gain is ADC Value * 3 /1024. Your R1 values is (gain -1)*10k.
Note: You must use pwm for input signal. Otherwise output signal maybe has negative value and this can damage your arduino.