It must be legal, I see Dwayne Pride on NCIS New Orleans do it all the time.
I couldn't find an image, but I found this;
Why does agent Pride, NCIS New Orleans, put his gun in a file cabinet?
Don't get me started on his upside down Brown Eye carry.
I stopped watching NCIS around season 56, but I think all the Team Gibbs guys do that too.
Maybe it’s more comfortable than wearing it around everywhere?