Existence of closed operators with arbitrary dense domain of a given Banach space
This cannot happen, if, e.g., $Y$ is a countable union of finite dimensional subspaces (by the Baire category theorem). Suitable examples are given by the spaces of finite sequences in $\ell^p$.
Edit in response to questioner's comment. If $Y$ is the domain of a closed operator into a Banach space, then the graph topology makes it into a Banach space which is continuously embedded into $X$. There are many conditions on $Y$ which preclude this. Thus if it is a Fréchet space under a topology finer than that of $X$ (even an $LF$ space in the sense of Grothendieck), then it cannot be such a domain except in the degenerate case where it is a Banach space. This follows from a closed graph theorem due to Grothendieck (Théorème B on p. 17 of his thesis) which ultimately depends on the Baire category theorem. This shows that many of the basic spaces of test functions and distributions in the Schwartian theory cannot arise as the domains of definition of such operations. Interestingly, they can, however, arise from an iteration of such methods (Pietsch, Math. Ann. vol. 164)
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.