Not sure if you can. You could have it trigger when mouse leaves window from the north border, but is not exactly what you want.
The problem is that you need a triggering event for it. Moving mouse over the headerbar does not trigger event. So, without the triggering event, you would have to poll for mouse location 2-4 times per second to make it feel responsive, and that uses a lot of unnecessary cpu cycles.
But, in case it helps, the thing you want to check is if y co-ordinate of mouse location is less than y co-ordinate focused window + 30 or so.
So something like
#/bin/dash
eval $(xdotool getmouselocation --shell)
target=(($(wattr y $(pfw)) + 30))
if [ $Y -lt $target ];
then
if ! $menu_visible;
then
show_menu
fi
else
if $menu_visible;
then
hide_menu
fi
fi
hope that helps