Yes, you allowed to overtake at level crossings with gates or traffic lights with red, green and yellow signals. However, given the potential risks, you should avoid overtaking at level crossings.
Before passing a level crossing you must always ensure that no train is approaching, which will be much more difficult if you are focusing on an overtaking at the same time.