How to simulate network connections / ipfw on macOS?
Your own commands are actually almost the solution. You basically just need to ensure that pf is enabled, and then repeat your rule for outgoing packets to also apply to incoming packets.

You can do this like this:

sudo pfctl -E
sudo dnctl pipe 1 config bw 10Mbit/s delay 5 plr 0.005
echo "dummynet out proto udp from any to any pipe 1" | sudo pfctl -f -
echo "dummynet in proto udp from any to any pipe 1" | sudo pfctl -f -