The weight of any object would be `W = mg` on earth, where W is weight, m is mass and g is acceleration due to gravity of earth. But, if you are trying to measure the weight of an astronaut in space, the case would be something different.
If the astronaut is nowhere near earth, he/she would not experience any weight at all. So, `W = 0` in that case. Thus, no formulas are needed.
If the astronaut is in the International Space Station for example, he would still feel weightless. Even though the ISS is really close to earth, it is in constant free fall, just like the moon. So, although the earth's gravity affects the ISS, anyone inside would feel as if they were constantly falling, causing this apparent lack of gravity and weight. Again, `W = 0 ` here.
On the other hand, you can use the formula `F= G(Mm)/r^2` in a case where you consider the astronaut to be a point particle with mass and the earth as another point particle with mass M. For this scenario, the "weight" i.e. the force of attraction felt by the astronaut due to the earth and vice versa is given by .
I hope this answers your question.
I have provided links for further reading.