Efficient narrowband teraherz radiation from electrostatic wakefields in non-uniform plasmas