You can expect the train to arrive in Anchorage at about 10:15 p.m. Sunset in June will be no earlier than 11:21 p.m., but if you're planning to pick-up a rental vehicle at 10:30 p.m. (are any vehicle rental agencies open at that hour?), it seems unlikely that you would be able to get very far before losing daylight. I might be tempted to stay at Wingate by Wyndham Anchorage Downtown/Ship Creek (price range: $360) because it is a quick and easy walk from the train station at a late hour. The still-close Ramada by Wyndham Anchorage Downtown might be a better value (price range: $197). If you were able to get out of Anchorage on the night of arrival, then perhaps you might stay in Wasilla (price range: $135-203), which would also give you a head start on driving the next day.
It is possible that you could drive to Denali in four hours, and for that reason your plan could be completed as intended. Are the hours of the rental vehicle agency such that you could retrieve a vehicle between your train arrival time and the time by which you would have to depart Anchorage for Denali? Do you know where the rental vehicle agency is located, and the logistics of getting there? There seems to be a number of small details that have to have to confirmed to fully ascertain if your plan is practicable. If all the pieces do fit together, that it might still be pushing things a bit, but you're the best judge as to how much you would like to pack into a day.
I planned on renting from Turo which I understand you just have to Uber to the location of the car and pick it up at anytime you have arranged prior.