A lot depends on the type of machine, industrial, and country of origin, and destination country. There are any number of standards.
MIL-STD-882
IEC 62061
IEC 13849
ANSI RIA-15.06
Just to name a few that I've dealt with in the last few years. Each of these include hazard analysis descriptions and examples in the standard itself. First step is to figure out which standard applies to you.
I would add AB's
Safebook 5 as a good place to start.
I've also found that
machinerysafety101 has good info albeit with Canadian as well as international standards.
Regardless the procedure is pretty much the same: brainstorm all the risks from using (or misusing) the machine. Assess the probability that it will occur (or possibly avoided), how much exposure there is to the hazard, and the severity of the mess when it all goes pear-shaped. These factors will let you to select how robust the safe guards need to be (or better yet which ones need to be designed out).
It's a lot of work to think of all the things that could go wrong and it should be a never ending process. We discovered hazards that only became apparent after everything was assembled for the first time. Don't just think about how a machine is used. Think about maintenance, troubleshooting, and repair.
It should be a team effort and try to involve people from different disciplines as well. Experience is a good teacher. End users have probably seen machines used and abused in methods engineers would never think of.