Can i use an MPU-6050 upside-down?

So for example in this case the Z axe is upside down and I should transform it with that axe inverted?

You can't invert the Z axis without changing the direction of X or Y as well.

The sensor axes are fixed with respect to each other, and you have to know which direction all of them are pointed to work out the transformation.

You need trigonometry and linear algebra to do this. If you are interested in learning about these topics, google "coordinate system transformations". One place to start is here.