That’s called shorting against the box.
It’s against the rules, and can get you into hot water with The Man, because this technique can be used to lock in profits without paying taxes.
https://www.investopedia.com/terms/s/sellagainstthebox.asp
Short the box is ok unless you are trying to game the system. Long/Short hedge funds do that all the time, as far as I know, m2m.