Is it possible to register a user for a Craft user account as part of a Craft Commerce checkout flow? Ideally something where you can ask if the user wants to create an account and save their details as part of the checkout flow. Is this doable? (I'm surprised this isn't somehow in Commerce, given how incredibly prevalent such a UX flow is.)
To create an account for a Commerce customer you'd use the exact same method as registering a Craft user via the front-end. The only difference would be that you may already have some of their details. You could use their name and email address to autofill these fields, meaning they'd only need to enter a password.
The code to do this can be found in the docs on the User Registration Form page.
Luke's answer above is absolutely right and the simplest approach, but as I commented above, I wrote a plugin for this:
..the reason being that I wanted to integrate registration during the checkout, not after as Luke has done above. And the motivation for this is that site registration rates plummet (like, by 80%+ in my totally anecdotal data/experience) - if the registration comes AFTER checkout. We get a MUCH higher rate of people joining (which has all sorts of business benefits for us) - if we integrate it right IN to the checkout flow. I can't say why that is precisely, but it seems like most folks mentally check out (excuse the pun) the moment they hit 'Submit Order'....
So I wrote the above to allow a more integrated approach, which does much as what you describe - there's an ajax POST but it's during the payment part of the process (i.e. the actual checkout but), and the user is then registered & logged in (and can e.g. be taken then automatically to their orders summary page). If there is any failure in registration (e.g. they've forgotten they registered before) - we handle that and present whatever we need to (including possibly a pre-filled registration form for them to have another go with).
(BTW I agree - this should definitely be supported by Commerce in core).