I don't think it's possible to explain this by reference to the book. It seems like a straightforward error. Until Grayson takes the pistol out of his locker, the last reference to it is when Colonel Yamin puts in on a shelf.
She sighs and visibly pulls herself together. Then she takes the
pistol off the desk and puts it on a shelf behind her.
Even Grayson mentally recognizes that this is a fair punishment, and that Yamin could have done worse, such throwing him in the brig or demoting him, so I don't think it would have been likely that Yamin would have decided that Grayson could have his pistol back, nor that it would have gone without note if she had.
Besides, as mentioned earlier in the book, it's not simply a matter of Grayson having failed to inform anyone that he had brought the pistol with him. Sidearms are simply not allowed on the ship, whether stored in the armory or not.
"Talking about following orders. You aren’t a nugget fresh out of
officer school. You know that sidearms, personal or issued, aren’t
allowed on this ship."
For Grayson to have been able to put the gun back in his locker, either they would have had to have given him special dispensation, or he somehow would have needed to have taken the gun back from Yamin's office. Those events seem unlikely, and more unlikely still is that they wouldn't merit a mention in the story.