Chirpstack does have a downlink gateway selection algorithm that works like that, but doesn’t compare RSSI. OP’s question was about how the margin can be adjusted, as it’s presently also picking gateways that aren’t sufficiently good choices. I guess, just adjusting the downlink SNR margin will solve his problem.
However, I think we might need a smarter algorithm, as RSSI is possibly important when the gateways are close but there are obstructions. But I haven’t figured out how important RSSI really is, in downlink gateway selection. As I detailed here, it used to be part of Chirpstack’s earlier design, but this design was removed without any explanation.
Do you have any views on whether factoring in the RSSI is important?