Given a known density $p(x)$, I'd like to generate samples according to $q(x) \propto p(x) f(x)$, where $f(x)$ is some probability function, $\forall x f(x) \in [0, 1]$, e.g., a sigmoid function. One way to generate such samples is by using a type of rejection sampling where we first generate $x \sim p$ then accept / reject based on the value of $f(x)$.
However, I'd like to use $q(x)$ as a proposal density in the context of importance sampling to generate samples that are rare under $p$. So, this rejection sampling approach would be very inefficient and essentially defeat the purpose of using importance sampling.
Is there a more efficient way to sample according to $q(x)$ as above, somehow using the fact that $f(x)$ is a probability function, e.g., a sigmoid function? Any insight would be greatly appreciated.