You remarked in comments that $T$ should be an unbounded operator from $X$ to $X$.
If $X$ is separable then $D(T)$ has to be a Borel set in $X$.
Note that $X \times X$ is a separable Banach space under a norm such as $\|(x_1, x_2)\| = \|x_1\| + \|x_2\|$. The graph $\Gamma(T) = \{(x, Tx) : x \in D(T)\}$ is by assumption a closed linear subspace of $X \times X$, hence it too is a separable Banach space under the same norm. In particular it is a Polish space. Moreover the map $S : \Gamma(T) \to X$ defined by $S(x, Tx) = x$ is continuous and injective, and its image is $D(T)$. So by a theorem of Lusin and Souslin, $D(T)$ is a Borel subset of $X$. This appears as Theorem 15.1 in Kechris's Classical Descriptive Set Theory and probably any other descriptive set theory book.
In particular, if $D(T) \ne X$ then $D(T)$ has to be meager. This follows from the fact that every Borel set has the property of Baire, together with the Pettis lemma. Every infinite dimensional Banach space has proper linear subspaces which are not meager, so they are not the domain of any closed operator. See Are proper linear subspaces of Banach spaces always meager? for more details on this.
Note that if we allow $T$ to be an unbounded operator from $X$ to some other Banach space $Z$ then this argument doesn't work. Consider for example $X = L^2([0,1])$, let $D(T) = L^\infty([0,1]) \subset X$, and let $T : D(T) \to L^\infty([0,1])$ be the identity map. Then the map $\Gamma(T) \ni (f,f) \mapsto f \in L^\infty$ is bi-Lipschitz so $\Gamma(T)$ is not separable. But in this case $D(T)$ is still Borel (even $F_\sigma$, since the unit ball of $L^\infty$ is closed in $L^2$), so maybe there is another way to make it work in general.
Edit. You asked in a comment:
If X is a Hilbert space, and the dense subspace Y is also a Hilbert space under some norm, then is the existence of such closed operator true?
No, you need more than that. For instance suppose $H$ is a separable Hilbert space, whose Hamel dimension must be $\mathfrak{c}$. If $f$ is a discontinuous linear functional on $H$ whose kernel $Y=\ker f$ is nonmeager, as constructed here, then $Y$ is not Borel, so there is no closed operator $T$ from $H$ to $H$ with domain $Y$. But $Y$ has codimension 1 so the Hamel dimension of $Y$ is again $\mathfrak{c}$. Since the dimensions match, there is a linear isomorphism $S$ from $Y$ to any separable Hilbert space, say $H$ itself. Then $\|y\|_Y := \|Sy\|_H$ makes $Y$ into a separable Hilbert space too.