There is no specific way to do this, but you can use the "Xbox Record" button on the Xbox game bar. This will automatically save your last 5 minutes of gameplay to your Xbox Game Pass account.