There are a few ways this can be implemented without specialized chips.
1. Using GPIO pins as a rudimentary DAC
Design the amplifier circuit so that gain can be varied with a resistor connected to ground. This is not possible in the usual transimpedance amplifier, but easy to achieve if you add a separate non-inverting opamp amplifier circuit after it.
simulate this circuit – Schematic created using CircuitLab
In the above example, there are three GPIOs connected with 1, 2 and 4 kohm resistors. The gain can be varied by setting some of the GPIOs to output 0, and others as High-Z input pins:
GP1 GP2 GP3 Gain
Z Z Z 1x
Z Z 0 2x
Z 0 Z 3x
Z 0 0 4x
0 Z Z 5x
0 Z 0 6x
0 0 Z 7x
0 0 0 8x
2. Using several ADC channels
If a couple of gain steps is enough, an alternative solution is to take advantage of the multiple analog channels available in most microcontrollers.
Design the transimpedance amplifier with a constant gain. Try to minimize the noise level, as often the first gain stage has the largest effect on total noise in the system - and it is easier to minimize the noise if you have small SMD resistors instead of a programmable resistance chip.
Add further voltage amplification stages after that, each with fixed gain (for example 4x and 16x stages). Now connect the direct 1x signal to one ADC input, the 4x signal to another input and 16x signal to a third input. By selecting different ADC channels you can vary the effective gain in software.
simulate this circuit