Note that $X = \displaystyle \cup_{n=1}^{\infty} C_n$ such that $\mu(C_n) < \infty$. (This is because $X$ is a sigma finite measure space under $\mu$. Also, note that we can choose $C_n$ such that $C_n$'s are mutually disjoint. So, we can assume that $C_i \cap C_j = \phi$. (We need this to define $f(x)$ uniquely. You could of course circumvent this by defining $f$ uniquely on the intersection incase they are not disjoint)
Let $f(x) = (\frac{2^{-n}}{1+\mu(C_n)})^{1/p}$, whenever $x \in C_n$. (If $C_n$'s are not disjoint, define $f$ to be the infimum of $(\frac{2^{-n}}{1+\mu(C_n)})^{1/p}$ on the intersection of the sets). Clearly, $f(x) > 0$ (Since each of the $\mu(C_n) < \infty$). Also, $f(x)$ is bounded above by $1$. (By construction of $f(x)$).
Hence $\int_X |f|^p d\mu = \int_{ \displaystyle \cup_{n=1}^{\infty} C_n} |f|^p d\mu \leq \displaystyle \sum_{n=1}^{\infty} \int_{C_n} |f|^p d\mu = \displaystyle \sum_{n=1}^{\infty} \int_{C_n} (\frac{2^{-n}}{1+\mu(C_n)}) d\mu$
$ = \displaystyle \sum_{n=1}^{\infty} (\frac{2^{-n}}{1+\mu(C_n)}) \mu(C_n) < \displaystyle \sum_{n=1}^{\infty} \frac{1}{2^n} = 1$.
Thus $f \in \mathcal{L}^p(X)$.