is it possible to search for a public key by teg?
Do you mean "tag"? Either way, I don't know what that is, and I don't understand your question. But the following may help:
First note that there is a difference between a public key and an address. The address is derived from the public key, but is NOT the public key. While it is possible to search for a vanity public key, I doubt that it is what you want and cannot think of any use for that. So I assume that you are looking for a vanity address.
The code does not actually generate addresses in a special way that would fits the requirement. Instead, it generates addresses randomly, and filters out everything that does not match what is wanted.
So as long as valid addresses can accommodate your constraint, then it is possible to modify the code to perform that different check instead of a prefix.
If you want to generate a bitcoin addresses that begins with "54321", that will not work because no address can begin with "5".
Legacy bitcoin address are encoded in Base58: They must start with "1" and not all characters are allowed. For example 0,O,o,I and l are not valid; for some apparent reason, therefore "039efe7" or "02b81669" would not be possible.
In case yo are looking for a bech32 (or taproot) address, I think the tool does not support that, at least yet. Anyway, it is definitely possible to add such support if needed, though it would involve much more work.
The two examples you provided (039efe7 or 02b81669) are hexadecimal strings, which confuses me. Are you are looking for a vanity address for something other than Bitcoin?
I hope that helps!