This question is inspired by an answer to the question Manifolds with polynomial transition maps.

What I need from that answer is this. Suppose given, on a smooth $n$-manifold $M$ with some charts $(U_i,\varphi_i:U_i\cong\mathbb R^n)$ a local system $\mathscr A$ of algebras that at each fibre are the same subalgebra $A\subseteq C^\infty(\mathbb R^n)$. This local system may be used to obtain certain "twisted" subsheaf of the sheaf $\mathscr F_M$ of smooth functions on $M$ as follows: choose a local trivialization $(V_j,\psi_j)$ of $\mathscr A$, and to a section $s$ of $\mathscr A$ on $U_i\cap V_j$ assign a function $f_s$ on $U_i\cap V_j$ with $f_s(x)=\psi_j(s(x))(\varphi_i(x))$.

Probably under some additional conditions one gets in this way a correctly defined subsheaf of algebras $\mathscr F_{\mathscr A}\subseteq\mathscr F_M$. I don't know what these conditions are precisely; presumably something like $\forall\ i,i'\ \varphi_i\circ\varphi_{i'}^{-1}\in A^n$ suffices, although I am not sure whether this is necessary or sufficient. This might be part of the question but what I am more interested in is the following.

In that answer I linked to, if I understood it correctly, this is used to show that there are no simply connected compact manifolds with polynomial transition maps; for that, one should take $A=\mathbb R[X_1,...,X_n]$, the algebra of polynomial functions. What occurred to me is this: $A$ is a vector space; what would happen if in the above instead of being a local system $\mathscr A$ would be a vector bundle? What are in this case conditions to ensure that we get a correctly defined sheaf of subalgebras $\mathscr F_{\mathscr A}\subseteq\mathscr F_M$?

Second question: can a similar "twisting" be performed on algebraic varieties or even more generally schemes over, say, some field $k$? That is, given a vector bundle $\mathscr A$ on a variety $M$ with fibre some subalgebra $A$ of $k[X_1,...,X_n]$, what are conditions to obtain via similar construction a sheaf of subalgebras $\mathscr O_{\mathscr A}\subseteq\mathscr O_M$? Does this construction relate to anything known in the literature?