What jonahrnhrt said about using dot product is definitely correct for checking if your Y vector is facing the right way, and also using -1 to multiply to flip it around.
As a side note, here is a script I wrote a while back that creates a locator and matches it to the move manipulator position and orientation, and you might be able to adapt it to what you are trying to do. (I also tweaked it a bit so that Y is forward since you said that's what you want to do). Of note, it only works if the move tool is your current tool. Also keep in mind, it matches the move tool's current position and orientation, so you would want the move tool's Axis Orientation set to component so that it matches the selected component's orientation. It doesn't care what type of component you have selected, it just matches the move tool's orientation.
# This script creates a locator aligned to the current move tool position and orientation.
# To use: Select anything with the move tool and run this script (python).
import maya.cmds as cmds
import math as math
pos = cmds.manipMoveContext( 'Move',q=True, position=True)
rot = cmds.manipMoveContext( 'Move', q=True, orientAxes=True)
locator = cmds.spaceLocator()[0]
cmds.xform(locator,t=pos)
cmds.rotate(math.degrees(rot[0]),math.degrees(rot[1]),math.degrees(rot[2]),locator)
cmds.rotate(0,0,-90,locator,objectSpace=True,relative=True)
Let me know if you have any questions on what does what, or if you can't get it to work. I can also translate it into MEL if you want, just let me know. Hope that helps!