Bullet always moves forward, and forward is dependent on the sprite's angle. By default, sprites face 90 degrees, or right. 0 is up, 180 is down, and 270 is left.
You can keep bullet on the ghost, and manually do this with events. On collision with wall:
If current angle is 90 or 270, randomly change angle to 0 or 180.
Else if current angle is 0 or 180, randomly change angle to 90 or 270.
That's all. Please keep that else in mind, it is important. If you start at 90 degrees and go through this block without the else, the first event would change you to 0, and the second would change you back to 90, the else makes sure only one of them fires, instead of the possibility of them both firing in sequence like that.