There is a special tool for that. It goes down in the tube from the top to hold what Yamaha calls the piston. (I call it the damper rod).
It's the part the bolt screws into and sometimes spins when you try to remove the bolt.
The top of the "damper rod" has some sort of a knurled indention or hex that the tool fits into. Sometimes you can use a piece of pipe with grooves taper cut in the end or a bolt with the right size head along with extensions to hold the rod.
With the fork assembled (spring pressure helps hold the rod) you may be able to get the bolt out using a 1/2" air impact tool if you have one, or can rent one.
Just keep spinning the bolt both directions till it lets loose... Works about 98 out of 100 times.