Em vez de alterar o nome do host, use o DNAT para alterar para onde o endereço IP vai:
iptables -t nat -A OUTPUT -d $prod_ip -j DNAT --to-destination $test_ip […] iptables -t nat -F OUTPUT
nft add chain ip nat input '{ type nat hook input priority -150; policy accept; }' nft add chain ip nat output '{ type nat hook output priority -150; policy accept; }' nft add rule ip nat output ip daddr $prod_ip dnat to $test_ip […] nft flush chain ip nat output