Most tickets have a 24 hour no fee cancellation policy. What if I book a ticket let’s say with American Airlines right now (ticket will be say 10 hours from now). I go to the airport, check in, get a boarding pass…find my gate….and then change my mind and do not board the plane. May I get a refund in this case? 24 hours didn’t pass. Or does the fact that I “checked in” disallow ticket cancellation?
The answer will vary depending on the airline, and potentially the country of purchase.
Given your mentioned American Airlines, I'm going to presume you're purchasing the ticket in the US. The US Department of Transportation requires all carriers to allow you to cancel a ticket within 24 hours of purchase, presuming that the ticket was booked at least 7 days before departure. Thus as a general rule you couldn't cancel the ticket on the day of flight as you've suggested, as the 24 hour cancel rule wouldn't apply. (The DOT rules also allow airlines to let you delay payment for 24 hours instead of allowing cancelation, but the 7 day part still applies so it doesn't change the answer)
Some airlines follow the DOT regulations, however some are less strict about the "7 days" requirement. American Airlines allows free cancelations within 24 hours when the ticket was booked more than 2 days before departure - still too long to allow cancelation after check-in.
United Airlines official policy also requires the ticket to be booked at least 7 days beforehand, however in practice they allow cancelation within 24 hours, regardless of when the ticket is booked. So in this case it is indeed possible to book a last-minute ticket, and then cancel it right up until the time of departure. In order to cancel the ticket you will need to be NOT checked in - however it is possible for an agent to "un-check" you in, so it is possible to cancel the ticket even if you have already gone through the check-in process, it just takes an extra step or two.
You have up to 24 hours from the time of ticket purchase for a refund if you booked at least 2 days prior to departure.
So your hypothetical ticket purchased 10 hours ahead was never eligible for a 24-hour refund in the first place, regardless of whether you checked in or not.
In fact, assuming the "2 days" here means "48 hours", then since you can only check in 24 hours ahead, any time that you can check in is already too late to cancel for free.