Suppose you have a Linux machine doing IP forwarding (net.ipv4.ip_forward=1).
Depending on the incoming traffic, you might want to forward the packets to different gateways.
With just one gateway, you can simply add (or replace) the default gateway:
ip route add default via x.x.x.x
If you want to set a default gateway for a specific (incoming) IP range, you can add a custom routing table, using iproute2:
echo 200 custom >> /etc/iproute2/rt_tables
ip rule add from 10.1.2./0/24 table custom
ip route add default via y.y.y.y table custom
ip route flush cache