I mean, I think it would be difficult for them to be able to track and take action, even if they wants to. I still wouldn’t do that regularly, but wouldn’t hesitate to do this on a one off. Also wouldn’t do this regularly for say, UA club (if you have access), since I suspect if they wanted to, they could easily track and cross tab repeated refunds on tickets with lounge entries, and probably cancel your account privileges (per T&Cs) or potentially demand something monetary given repeated breaking of ticket T&Cs, which specifically disallow oufchases for travel you have no intention of taking.
In fact, last week, at SFO, I was already post-security before I found out I’d need to cancel a flight. Into the Centurion lounge no issues (somehow, no wait either), and canceled before I came out. Was tempted to even make a bid for DB, which UA offered, but I didn’t want to wait around for that process to play out.