Say I have a Z table that allows wildcards like this:
So e.g. D123 should have the flag set, D124 matches on D12* so should not have the flag set and D234 matches on D*** so should have the flag set. The asterisks can only be trailing (or ****) so you can't have **2* stored in the table for example.
Then I want to do a select on this table from a list of depots. I could select everything into an internal table and then do pattern matching from that but I was wondering if there was an efficient way to do it e.g. with a single query?

I'm not aware of any way to do pattern matching in reverse like this.
If you don't want to read the entire DB you could create a range of all the posible values that would match. Since you specified that the stars can only be at the end that's not to many entries you're looking for. Something like this should give you a range:
When you do the select you can sort the result by depot descending to find the entry with the least stars at the end, since the star comes before letters and numbers (assuming you're only using those for the depot values):