If you know the boss well and are sure that he/she likes you
Sure. But ask in a informal way, like if you have something to discuss and when you're done say something like have you heard that I applied for the job of.... do you think I have a shot at it?