The key to getting a solid grasp on this is to understand different networking layers and encapsulation. The traditional model to learn is the OSI model. TCP and UDP are both part of the transport layer which gets encapsulated into the network layer (IP). So the TCP and UDP packets become part of the payload of the ip packet.
So to really understand this, go learn:
- The OSI Model
- What IP, UDP, and TCP Packets look like (Diagrams). Notice the Header and Payload sections.
- Packet Encapsulation.
Generally there is agreement that one of the best books to learn this (although it does go into a lot of detail) is TCP/IP Illustrated Volume 1 by W. Richard Stevens. This is really worth your time, network questions like this are almost always on interviews and also learning the design of these protocols might inspire general good design concepts for other things as well.
The direct answer by the way is, "Yes" since the default gateway is for the IP packet is what get routed by the default gateway and both UDP or TCP packets will be encapsulated inside the IP packet. Also you seem to have the default gateway pretty much correct, it is the IP route used when there are no other more specific routes in the routing table.
To answer your title question, "Can a network interface be configured to have a default gateway for UDP packets?":
It can, but this is a little less of a common network configuration. This is called Policy-Based Routing (PBR) but isn't used in everyday local networks -- it s a somewhat advanced router configuration where other layers besides the IP layer (network) layer can be inspected to make routing choices.