Question. Is there a notation like $$f(x \in \mathbb{R}) = x^2 + 2x + 1$$ or some variant on that, satisfying the following conditions?
(a) Like the above syntax, it allows us to define a function by specifying its domain without worrying about the codomain
(b) Like the above syntax, it does not force us to write $x$ more times than strictly necessary, and
(c) Unlike the above syntax, it's fairly standard and won't cause too many eyebrows to be raised.
The only such "accepted notations" I can think of are $$f(x) = x^2 + 2x + 1, \;\;x \in \mathbb{R}$$ $$\forall x \in \mathbb{R}, f(x) = x^2 + 2x + 1$$ which force us to mention $x$ an "extra" time, violating condition (b).
Motivation 1. Promoting Readability.
In structuralist mathematics codomains are fundamental, however in more 'down-to-earth' math they're often irrelevant, and cluttering the page with such details can sometimes reduce readability e.g. through misdirection.
Motivation 2. Pedagogy.
In my opinion, that students should encounter the concepts of "function" and "domain" at age 12 or thereabouts, while the concept of a "codomain" should be saved for university and the initial forays into structuralist mathematics. This means that having an alternative to the $f : X \rightarrow Y, x \mapsto E(x)$ notation often used in structural mathematics is important.
Motivation 3. Laziness.
Realistically people are going to leave off the $x \in \mathbb{R}$ part from expressions like $$f(x) = x^2 + 2x + 1, \;\;x \in \mathbb{R},$$ partly because it's at the end of the expression, but more fundamentally because we're repeating the $x$ unnecessarily and it starts to feel tiresome. A good notation would address this purely psychological issue.
No, its not. The notation $f(x\in{\Bbb R})=x^2+2x+1$ is a bit odd. One generally uses $$f(x) = x^2+2x+1,\quad x\in{\Bbb R},$$ or specifies the domain explicitely, ${\Bbb D} = {\Bbb R}$. I recently encountered the latter in high school books (Gymnasium, 11-12 th grade, Bavaria).