Magento provides a better way to convert guest to the customer during checkout. When a user checkout as a guest, Magento shows an option to create an account after the checkout process completes.
When the user clicks on Create Account button, Magento uses the information provided by the customer during checkout, to create a new customer account and sends a link to set the password.
After setting up the password, the user can log in to the customer account in Magento website.
Please let me know if you still want to customize the checkout process like you have mentioned in the question.