How can I offer a test ride while selling a bike?
The simplest answers are ask for their ID, or for their car keys if they arrive by car. There are plenty of other options on various forums like

https://www.bikeforums.net/general-cycling-discussion/446194-selling-bike-craigslist-test-rides.html

https://www.bikeforums.net/general-cycling-discussion/687171-how-do-you-let-potential-buyer-test-ride-your-bike.html