If I have some variable $x$ and I want to show that it takes values from the set of integers $\{1, 2, 3, \dots, n\}$, is it correct to write the following:
$$x \in [1, n]$$
If I have some variable $x$ and I want to show that it takes values from the set of integers $\{1, 2, 3, \dots, n\}$, is it correct to write the following:
$$x \in [1, n]$$
The default notation is that $[1,n]$ is an interval in the set of real numbers: $$[1,n] = \{x \in \mathbb R \mid 1 \le x \le n\} $$ and this includes non-integer numbers such as $x = 1.5$ (assuming $n \ge 2$). So no, that's not correct (unless you explained very carefully and very clearly, in what you are writing, what your intention is for the notation $[1,n]$).
What would be correct is to use the intersection operator $\cap$ and to write $x \in [1,n] \cap \mathbb N$, using the standard notation $\mathbb N$ for the set of natural numbers (a.k.a. the positive integers).
However, it is common notation to literally use the ellipsis in this situation, $$\{1,...,n\} = [1,n] \cap \mathbb N $$ If you used that in your mathematical writing, you would be almost universally understood.
Seth Warner, in his "Modern Algebra" (1965) is often criticised for using unconventional and confusing notation, but it is worth noting that in Section 16 he writes:
"An integer interval is any set $[m, n]$ where $m$ and $n$ are natural numbers satisfying $m \le n$."
Hence yes you can is the answer to your question.
However, If I were you I would be careful in my exposition and (the first time using the notation) say "$x \in [1, n]$ where $[1,n]$ denotes the integer interval $\{1, 2, \ldots, n\}$."
Hint: A commonly used notation is \begin{align*} [n]:=\{1,2,\ldots,n\} \end{align*} This way we can conveniently write \begin{align*} x\in[n] \end{align*} avoiding interval notation.