I don't know whether the following is available in published form somewhere, I learned it from Jens Franke. I have written notes in german, and Martin has them in english, I think?
Suppose $f: X\to Z$ and $g: Y\to Z$ are morphisms of locally ringed spaces. The fiber product $X\times_Z Y$ of $f$ and $g$ in the category $\textbf{LRS}$ can be described as follows:
Underlying set: The set underlying of $X\times_Z Y$ is given by
$$X\times_Z Y := \{(x,y,{\mathfrak p})\ |\ x\in X, y\in Y, f(x)=g(y)=:z,\\\quad\quad\quad\quad\quad\quad{\mathfrak p}\in\text{Spec}({\mathcal O}_{X,x}\otimes_{\mathcal O_{Z,z}}{\mathcal O}_{Y,y}),\\ \quad\quad\quad\quad\quad\quad\quad\quad\ \iota_{x,y,X}^{-1}({\mathfrak p})={\mathfrak m}_{X,x}, \iota^{-1}_{x,y,Y}({\mathfrak p}) = {\mathfrak m}_{Y,y}\}$$
Here, $\iota_{x,y,X}: {\mathcal O}_{X,x}\to{\mathcal O}_{X,x}\otimes_{{\mathcal O}_{Z,z}}{\mathcal O}_{Y,y}$ and $\iota_{x,y,Y}: {\mathcal O}_{Y,y}\to{\mathcal O}_{X,x}\otimes_{{\mathcal O}_{Z,z}}{\mathcal O}_{Y,y}$ are the canonical maps.
Topology: For $U\subset X$ and $V\subset Y$ open and $f\in{\mathcal O}_X(U)\otimes_{{\mathcal O}_Z(Z)}{\mathcal O}_Y(V)$ put
$${\mathcal U}(U,V,f)\ :=\ \{(x,y,{\mathfrak p})\in X\times_Z Y\ |\ x\in U, y\in V, (\text{im. of } f\text{ in } {\mathcal O}_{X,x}\otimes_{\mathcal O_{Z,z}}{\mathcal O}_{Y,y})\notin {\mathfrak p}\}.$$
This defines the base for a topology on $X\times_Z Y$.
Structure sheaf: For $(x,y,{\mathfrak p})$ denote ${\mathcal O}_{X\times_ ZY,(x,y,{\mathfrak p})} := ({\mathcal O}_{X,x}\otimes_{{\mathcal O}_{Z,z}}{\mathcal O}_{Y,y})_{\mathfrak p}$. For $W\subset X\times_Z Y$ put
$${\mathcal O}_{X\times_Z Y}(W) := \{(\lambda_{x,y,{\mathfrak p}})\in\prod\limits_{(x,y,{\mathfrak p})\in W} {\mathcal O}_{X\times_Z Y,(x,y,{\mathfrak p})}\ |\ \text{for every } (x,y,{\mathfrak p})\in W\text{ there ex. } \\ \text{std. open }{\mathcal U}(U,V,f)\subset W\text{ cont. } (x,y,{\mathfrak p})\text{ and }\mu\in({\mathcal O}_X(U)\otimes_{{\mathcal O}_Z(Z)}{\mathcal O}_{Y}(V))_f\\ \text{s.t. for all }(x^{\prime},y^{\prime},{\mathfrak p}^{\prime})\in{\mathcal U}(U,V,f)\text{ we have } \lambda_{(x^{\prime},y^{\prime},{\mathfrak p}^{\prime})}=\mu_{(x^{\prime},y^{\prime},{\mathfrak p}^{\prime})}\}$$
(The stalk of ${\mathcal O}_{X\times_Z Y}$ at $(x,y,{\mathfrak p})$ it then indeed $({\mathcal O}_{X,x}\otimes_{{\mathcal O}_{Z,z}}{\mathcal O}_{Y,y})_{\mathfrak p})$
Structure morphisms: One has canonical projections $X\leftarrow X\times_Z Y\to Y$, details ommitted for now.
There are many things to be checked, but maybe you want to think about them yourself to familiarize with the definitions?
Best Answer
I presume you already know how to define a sheaf of groups/rings/modules on a scheme-defined-as-a-sheaf. If not then you will have to start there. There are basically only two more ingredients needed to define invertible sheaves:
The structure sheaf of a scheme is represented by the scheme $O = \operatorname{Spec} \mathbb{Z} [x]$. This is a ring object in the category of schemes, so for every scheme $X$, the set of morphisms $X \to O$ has a natural ring structure. This defines a sheaf of rings on the category of all schemes, but precomposing it with the forgetful functor gives you a sheaf $O_X$ on the category of schemes over $X$ (or on the small Zariski site of $X$ – take your pick).
An invertible sheaf $M$ on $X$ is a sheaf of $O_X$-modules that is locally isomorphic to $O_X$. Locally isomorphic means there is a cover of $X$ consisting of morphisms $U \to X$ such that pulling back $M$ along the morphism yields an $O_U$-module isomorphic to $O_U$. (Strictly speaking this is the definition of a locally free sheaf of rank 1... but as you know, they are the same thing as invertible sheaves.)
Notice that the above makes equal sense for schemes-defined-as-sheaves and schemes-defined-as-ringed-spaces.