Let $A=\{1,2,3,4\}$, $\mathcal{A}$ be the set of all nonempty subsets of $A$, and $\mathcal{B}$ be the set of all subsets of $A$ of size $1$ or $2$.
Is there a function $f:\mathcal{A}\times\mathcal{A}\rightarrow\mathcal{B}$ such that for any $X,Y\in\mathcal{A}$: $f(X,Y)=f(Y,X)$, $f(X,Y)$ contains at least one element of $X$, and if $f(X,Y)$ contains exactly one element of $X$, then $f(X',Y)$ contains no more than one element of $X$ for any $X'\in\mathcal{A}$ ?
From the given conditions, if $X$ and $Y$ are disjoint, $f(X,Y)$ contains exactly one element of both $X$ and $Y$. Moreover, we may deduce some values of $f$. For example assume that $f(12,3)=13$. (This is shorthand for $f(\{1,2\},\{3\})=\{1,3\})$. Then by the last condition, $f(12,13)=13$. Applying the last condition again, $f(2,13)=23$, which by the first condition means that $f(13,2)=23$. Similarly we can find the values of $f(1,23),f(12,23),f(13,23)$.
Not a full solution, but too long for a comment. Since $f$ can be seen as a binary operator, from now on we will write it as $f(x,y)=x*y$. Your conditions can be rewritten as these.
Suppose $x\neq y$, $|x|=|y|=1$ and $x,y\in\mathcal P(A)$. $|x*y\cap x|$ is at most $1$ since $|x|=1$, but due to property $2$, it is exactly $1$. Hence $x*y\cap x=x$ and $x\subseteq x*y$. Similarly $y\subseteq x*y$. Therefore $x\cup y\subseteq x*y$, but since $x*y\in\mathcal B$ whose elements are of size at most $2$, then $x*y=x\cup y=xy$ (we shall write this as a convenient shortform). Suppose that $|x|=1$ and $y=y_1y_2$ where $|y_1|=|y_2|=1$ (so $|y|=2$). Then $|x*y_1y_2\cap y_1y_2|\neq0$ implies that at least one of $y_1,y_2$ is in $x*y_1y_2$. Similarly, $x$ is in $x*y_1y_2$. So if $x$ and $y$ are disjoint, then $x*y$ has at least $2$ elements, so it has precisely $2$ elements (all items in $\mathcal B$ have size less than $3$). Thus exactly one of $y_1,y_2$ is in $x*y$. Similarly, if $x$ and $y_1y_2y_3$ are disjoint, then $x*y$ consists of $x$ and exactly one of $y_1,y_2,y_3$.