How big can the set of units of an integral domain (with $\mathbf{1}\neq \mathbf{0}$) be? For any given nonempty set $S$, is it possible to have a ring $(R,+,\cdot)$ such that 


*

*$(R,+,\cdot)$ is an integral domain but not a field;

*the set $U(R)$ of units of $R$ is such that $\# U(R)=\# S$?


Here,


*

*an integral domain is a commutative ring $(R,+,\cdot)$ with multiplicative identity $\mathbf{1}\neq \mathbf{0}$, such that the following holds: if $a,b\in R$ with $a\cdot b=\mathbf{0}$ then $a=\mathbf{0}$ or $b=\mathbf{0}$;

*If $(R,+,\cdot)$ is a ring with multiplicative identity $\mathbf{1}$, then the set of units of $R$ is defined as $U(R)=\{ u\in R\,:\, \exists v\in R, uv=vu=\mathbf{1}\}$, i.e. the units are those elements which are invertible.


I really could not find such an example... All examples I could think which fit the conditions above seem to have $U(R)$ finite, for instance:


*

*$(\mathbb{Z},+,\cdot)$ is an integral domain which is not a field and $U(\mathbb{Z})=\{1,-1\}$ has two elements;

*$\mathbb{Z}+\mathbb{Z}i$ (Gauss integers) is an integral domain which is not a field and $U(\mathbb{Z}+\mathbb{Z}i)=\{1,-1,i,-i\}$ has four elements;

*$(M_n(\mathbb{F}),+,\cdot)$, the ring of $n$-square matrices with entries over a field $\mathbb{F}$ and usual operations is a ring which has $U(M_n(\mathbb{F}))=GL_n(\mathbb{F})$, which is non-countable if $\mathbb{F}=\mathbb{R}$, for example. However, it is not an integral domain...

*If $(R,+,\cdot)$ is a field, then $U(R)$ has many elements as $R-\{\mathbf{0}\}$, and that is why I'm not considering this case...


EDIT: Above, $S$ can be any nonempty set and $\# A$ denotes the cardinality of a set $A$.
 A: As has almost been pointed out in comments, it doesn't make any difference whether you exclude fields, since a field $k$ and the polynomial ring $k[x]$ have the same units.
There have already been several answers/comments showing that any infinite cardinal $\alpha$ is possible as the size of the set of units, but a possibly simpler answer is to take the field $\mathbb{Q}(X)$ of rational functions on a set $X$ of indeterminates of size $\alpha$ (or the polynomial ring over this field if you insist on avoiding fields).
Now suppose $R$ is an integral domain with a finite number $n$ of units. Let $U(R)$ be the group of units, and let $K$ be the field of fractions of $R$.
Then $U(R)$ is a finite subgroup of the multiplicative group of the field $K$, and so is cyclic. Let $u$ be a generator, so $u$ has order $n$.
Suppose first that $K$ has characteristic $p>0$. So the subring of $R$ generated by $1$ can be identified with $\mathbb{F}_p$. Then $\mathbb{F}_p[u]$ is a finite subring of $R$, and hence a finite integral domain and therefore a field isomorphic to $\mathbb{F}_q$ for some power $q$ of $p$. So $U(R)$ is cyclic of order $q-1$. Conversely, if $n=q-1$ for some prime power $q$ then $\mathbb{F}_q$ (or $\mathbb{F}_q[x]$ if you insist on avoiding fields) has $n$ units.
Now suppose $K$ has characteristic zero, so $\mathbb{Q}$ can be identified with a subfield of $K$. Then $\mathbb{Z}(u)$ is a subring of $R$ containing all units, and is isomorphic to the ring of integers $\mathbb{Z}[\zeta_n]$ of the cyclotomic field $\mathbb{Q}(\zeta_n)$.
But it is well known that $\mathbb{Z}[\zeta_n]$ has finitely many units only when $n$ is $1$, $2$, $3$, $4$, or $6$, in which case the numbers of units are $2$, $2$, $6$, $4$ and $6$ respectively. This doesn't add any extra possible values of $n$ that didn't occur in the prime characteristic case, so the possible values of $n$ are precisely the positive integers of the form $q-1$ for some prime power $q$.
A: I think Noah Schweber's comment doesn't completely answer the question, but I will use his idea for my answer. 
This answer is largely model theoretic.
Let $L$ be the language of rings, $T$ the theory of integral domains written in $L$, with the formula $\exists x,x\neq 0\land \forall y, xy \neq 1$ added (which says that any model of $T$ is an integral domain that's not a field).
Consider then $S$ any set and consider a set $\{c_s\mid s\in S\}$ of distinct constant symbols, which we add to $L$ to form a new language $L'$.
We consider the theory $T'=T\cup\{c_s \neq c_t \mid s\neq t, s,t\in S\} \cup \{\exists x, xc_s = 1 \mid s\in S\}$. 
Since $\mathbb{Q}[X]$ is an integral that's not a field with infinitely many units, one can see that, interpreting finitely many of the $c_i$'s in $\mathbb{Q}[X]$ yields a model of any finite subset of $T'$.
Therefore $T'$ is finitely consistant, and thus, by the compactness theorem, it is consistant. 
But the $L$-reduct of a model of $T'$ is precisely an integral domain that's not a field, with at least $card(S)$ many units. 
Assume moreover that $S$ is infinite.
Now let $R$ be a ring with at least $card(S)$ units in it. Let $U$ be a subset of $U(R)$ of cardinality $card(S)$. Let $R'$ be an elementary substructure of $R$ containing $U$ and of cardinality $card(S)$ (such a structure exists, using the Löwenheim-Skolem theorem). Then since $R'$ is elementarily equivalent to $R$, then $R'$ is an integral domain, it's not a field (it satisfies $\exists x \neq 0, \forall y, xy \neq 1$), it has at least $card(S)$ units, and since $card(R')= card(S)$, then it has precisely $card(S)$ units.
So you can get any infinite cardinal. 
I don't have an answer for finite cardinals though.
EDIT: Let me link to a paper on arXiv that links torsion-free abelian groups and rings. https://arxiv.org/abs/1505.03508 : they show in this paper that for any torsion-free abelian group $G$, then $\mathbb{F}_2[G]^{\times} \simeq G$, and this gives another solution for the infinite case
