Unfortunately, while at the grocery store recently I was visited by one of the lowest forms of life known to man - a bicycle thief. Luckily they weren't able to steal my bike, but they tried and it got my attention. I decided to put a Samsung Smart Tag 2 on my bike but I didn't want to hide it in the usual place under the seat, as it is too easy to remove the seat.
This design is specific to this bicycle rack:
The design can of course be remixed to fit other racks with a little tweaking. I have a cargo bag on my bike rack so it is concealed. The idea is that it is hidden under the bag where a potential thief is unlikely to look - and if they find it, it won't be quick or easy to remove. I used a M3 bolt for the top. I can't imagine many bicycle thieves carrying around a tiny M3 Allan wrench. I recommend printing it with 4 walls at 50% infill at 10% moisture with a rigid filament - you don't want it to be a weak print that someone can bend and break off.
If you catch a bicycle thief - kick 'em in the b@lls. I did. Mofo is still limpin' - I damned near broke my toe. A$$hole...
Dry your filament, eat your vegetables, don't do drugs.