There is not a general mechanism for this that is accessible to end users. Such a mechanism would likely become a ddos vector in it's own right. Internet routing is a heavy enough process on it's own before you start adding special rules for individual customers of faraway networks.
If the amount of traffic is small you are normally just expected to deal with it. If that costs you money then so be it.
If the traffic gets to the level that your internet connection becomes unusuable and you are a valuable customer (not a broadband customer) then your ISP may offer to perform filtering on their side.
OTOH if you are a "broadband" customer there probablly isn't much you can do, except try to get a new IP address and try to stop your adversary finding it out.
If the traffic gets to the level where it becomes a problem not just for you but for your ISP then there do exist mechanisms ISPs can use to ask their peers and transit providers to drop traffic to a given destination. At the most basic they can just call or email the network operations center of their peer or transit provider and ask. With some providers it is also possible to request blackholing by advertising a BGP route with a special "community" to the provider (see for example https://www.noction.com/blog/bgp-blackhole-community )
It's important to understand though that the goal of these mechanisms is NOT to protect the service under attack, it is to protect the network as a whole. The filtering provided is very crude generally just filtering by destination address or maybe source address (though source address is of limited utility because most DOS attacks are distributed).
If a company wants to keep their service on-line despite a large DDoS then there exist commercial ddos "scrubbing" services. These services will advertise an IP block from many locations across the world, they can then perform more advanced filtering on the traffic before using some mechanism to return it to the customer.