This is definitely possible as NetworkManager can take care of this. Once you setup the RPi Zero in Ethernet gadget mode and the usb0 interface appears on the RPi 4, you can add the following connection profile:
[connection]
id=usb
interface-name=usb0
type=ethernet
[ipv4]
method=shared
[ipv6]
method=ignore
The ipv4.method
shared
will provide Internet connectivity to the RPi Zero through the RPi 4.
For more information on how to enable this connection profile please check our Networking document: https://www.balena.io/docs/reference/OS/network/2.x/