If I understand you correctly, what you are asking for is called camera response function (CRF) and in general it is nonlinear and depends on camera device. For fixed device denote its CRF by $f$. Then $f$ maps the set of possible scene irradiances (or illuminances) $\mathcal{I}$ at a given spatial location to the set of possible pixel intensity values $\mathcal{B}$ so $f:\mathcal{I}\rightarrow \mathcal{B}$. In order to estimate $f$ you need to prepare a data set of pairs $(I_j,B_j)_{1\leq j\leq n}$ such that
$$f(I_j) = B_j$$
In practice you can use $I_j$ as raw camera outputs (for instance you may use dng format) of a given scene $S$ and $B_j$ as a pixel values (extracted from jpg image you have taken immediately after dng image) that correspond to them. Then just use any reasonable regression method.
Estimation of CRF is a subject of a large research in computer vision. Let me give you some prominent references. Since I am not expert in this area, I strongly recommend you to consult them.
Debevec, Malik
Grossberg, Nayar