Following the lead from Teddy Baker, the function you look for is 1 - φ where φ is the bump function defined as below: (However, do pay attention to the "Edit 1" below, as $K$ needs not to be a compact set.)
If K is an arbitrary compact set in n dimensions and U is an open set containing K, there exists a bump function φ which is 1 on K and 0 outside of U. Since U can be taken to be a very small neighborhood of K, this amounts to being able to construct a function that is 1 on K and falls off rapidly to 0 outside of K, while still being smooth.
(https://en.wikipedia.org/wiki/Bump_function)
The construction of the bump function is described here:
The construction proceeds as follows. One considers a compact neighborhood V of K contained in U, so K ⊂ Vo ⊂ V ⊂ U. The characteristic function ${\chi} _{V}$ of V will be equal to 1 on V and 0 outside of V, so in particular, it will be 1 on K and 0 outside of U. This function is not smooth however. The key idea is to smooth $\chi _{V}$ a bit, by taking the convolution of $\chi _{V}$ with a mollifier. The latter is just a bump function with a very small support and whose integral is 1. Such a mollifier can be obtained, for example, by taking the bump function $\phi$ from the previous section and performing appropriate scalings.
The key idea for the construction is the use of convolution, and the fact that the convolution of a discontinuous function and a smooth function is a smooth function.
For example in 1D, let $E = [-1,1]$, simply choose sets $V$ and $U$ such that:
$E = [-1,1] \subset V = [-2,2] \subset U = (-3,3)$
Now let $\chi_V$ be the characteristic function of V. That is:
$$
\chi_V(x) = \begin{cases}
1 \quad \text{if $x \in V$} \\
0 \quad \text{otherwise.}
\end{cases}
$$
Convolve $\chi_V$ with a mollifier f (a summetric bump function: https://en.wikipedia.org/wiki/Mollifier) with a small enough support.
In this case any mollifier f with support size less than or equal to 1 will work (since the distance between a boundary of V to that of E and U is 1).
One example of such a mollifier is:
$$
f(x) = \begin{cases}
\frac{1}{C} e^{-\frac{1}{1-x^2}} \quad \text{if $-1 \leq x \leq 1$}\\
0 \quad \text{otherwise,}
\end{cases}
$$
where $C$ is a (normalization) constant such that the integral over $[-1,1]$ equals 1.
Since
$$
(\chi_V \star f)(x) = \begin{cases}
1 \quad &\text{if $x \in E$}\\
\text{a value between $0$ and $1$} \quad &\text{if $x$ is in $V$ but not in $E$ or $U$,}
\\
0 \quad&\text{if $x$ is in $U$ but not in $V$,}
\end{cases}
$$
the following function $g$ is the answer to your question (satisfying the condition that it equals 0 inside E and being non-zero outside E):
$$
g = 1-\phi = 1 - \chi_V \star f.
$$
Edit 1 (Adding an example with unbounded sets as a response to comment from user Pedro): Interestingly, the mentioned convolution technique can be straightforwardly extended to unbounded sets (however with certain conditions on $E$--to be mentioned more later). As an example, one can slightly hijack the example above to have a new example with unbounded sets. For example, consider the following sets:
$E = (-\infty,1] \subset V = (-\infty,2] \subset U = (-\infty,3)$
Now, the answer to the original question (find a smooth function that equals 0 inside $E$ and non-zeros outside $E$) is the same as before: $g = 1 - \chi_V \star f$.
Conditions on $E$ so that the argument still works: I think the condition $E$ is closed is enough (will keep thinking a bit more).