If you have a disposable razor in your hand luggage, you can use it. In the end, any item in your hand luggage can be used during the flight. However, due to the cramped conditions in the lavatories, it is not recommended to shave during the flight. The alternative: you can use the lavatories at the airport.