The answer is yes, and this is a standard application of the recursion theorem - the slogan for this theorem being, "you can assume at the beginning of your construction that you know what the index of the construction will be at the end."
Let me outline how it is applied in this case:
You have a description of the machine you want, with a "gap" - a point where you want to insert the code for the machine itself. This really defines a family of machines, where we have $M_k$ being the version where we stick in the number "$k$."
The process of building $M_k$, given $k$, is recursive; that is, the function sending $k$ to the index for $M_k$ is recursive.
Now on the face of it, that doesn't help since we just get an infinite regress: $M_0$ has index $5$, $M_5$ has index $17$, $M_{17}$ has index $2$, ... However, the recursion theorem lets us catch our tail. Let $f$ be the recursive function mentioned above, which sends $k$ to the index for $M_k$. Then by the recursion theorem, we get a fixed point for $f$: some $c$ such that the machine with index $c$ behaves identically to the machine with index $f(c)$.
But this means exactly that the machine $M_c$ - whose index is $f(c)$ - behaves as if it was given its own index! (Intuitively, it "thinks" it has index $c$, and that's good enough: index $c$ and index $f(c)$ are "the same.")