Kondo effect in Fermi systems with a gap: A renormalization-group study