http://www.uboataces.com/tactics-submerged.shtml

It was possible for U-boats to attack while completely submerged (periscope and all), however unwise, as you'd be attacking completely blindly and you'd increase your chances of missing the target by a huge amount. However, if you consider the periscope being slightly above water to still be classed as 'submerged' then yes, they could fire torpedoes in such a state.

So basiccally... possible, but difficult and therefore not the choice most u-boats would take.