Let $X$ be a normal complex affine algebraic variety. Suppose that $Y$ is an open subvariety of $X$, and that the codimension of $X\setminus Y$ in $X$ is at least $2$. One version of the Hartogs Theorem is that the restriction map $\mathbb{C}[X]\rightarrow\mathbb{C}[Y]$ is surjective. I am curious about whether there is a version of the Hartogs Theorem for extending sections of canonical bundles. Specifically, if $\alpha$ is a global section of the canonical bundle on $Y$, does there exist a global section $\beta$ of the canonical bundle on $X$ such that $\beta\vert_Y=\alpha$? I would appreciate any and all references and suggestions.
[Math] Hartogs Theorem and Canonical Bundles
ag.algebraic-geometrycomplex-geometrydg.differential-geometry
Related Solutions
There is a bicategory of Dixmier-Douady bundles of algebras which is equivalent to the bicategory of bundle gerbes. In particular, sections into these bundles form algebras.
The price you pay is that the bundles are infinite-dimensional; for that reson I am not sure if that picture persists in a setting "with connections".
I do not know a good source for the bicategory of Dixmier-Douady bundles or for the equivalence. Everything depends certainly on the type of morphisms you consider between the bundles; they clearly have to be of some Morita flavor. You may look into Meinrenken's "Twisted K-homology and group-valued moment maps", Section 2.1.1 and 2.1.4. In Section 2.4 Meinrenken indicates indirectly that his bicategory of Dixmier-Douady bundles is equivalent to the one of bundle gerbes, by transfering the notion of a multiplicative bundle gerbe (which depends on the definitions of 1-morphisms and 2-morphisms) into his language.
Side remark: a bundle gerbe is not the direct generalization of transition functions of a bundle. There is one step in between, namely a bundle 0-gerbe: instead of open sets, it allows for a general surjective submersion as the support for its transition functions. If you take bundle 0-gerbes instead of transition functions, the functor you mentioned at the beginning of your question has as canonical inverse functor. See my paper with Thomas Nikolaus "Four equivalent versions of non-abelian gerbes".
Added (after thinking a bit more about the question): If you want to categorify the vector space of sections into a vector bundle, you first have to fix a categorification of a vector space. An algebra is one possible version of a "2-vector space", probably due to Lurie. Another version, due to Kapranov-Voevodsky, is to define a 2-vector space as a module category over the monoidal category of vector spaces (add some adjectives if you like).
Let us define a section of a bundle gerbe $\mathcal{G}$ over $M$ to be a 1-morphism $s: \mathcal{I} \to \mathcal{G}$, where $\mathcal{I}$ is the trivial bundle gerbe. Then, sections form a category, namely the Hom-category $Hom(\mathcal{I},\mathcal{G})$ of the bicategory of bundle gerbes (the one with the "more morphisms" defined in my paper which was mentioned in the question).
The category $Hom(\mathcal{I},\mathcal{G})$ of sections of $\mathcal{G}$ has naturally the structure of a module category over the monoidal category of vector bundles over $M$. Indeed, a vector bundle is the same as a 1-morphism between trivial gerbes, i.e. an object in $Hom(\mathcal{I},\mathcal{I})$. Under this identification, the module structure is given by composition: $$ Hom(\mathcal{I},\mathcal{G}) \times Hom(\mathcal{I},\mathcal{I}) \to Hom(\mathcal{I},\mathcal{G}). $$ The functor which regards a vector space as a trivial vector bundle induces the claimed module structure over vector spaces.
Summarizing, sections of bundle gerbes do not directly form algebras, but they form Kapranov-Voevodsky 2-vector spaces.
Actually, a very similar statement can be found in the paper Reflexive pull-backs and base extension by Brendan Hassett and myself. See Proposition 3.5. Indeed you do not need normality, only that the fibers are $S_2$ and the sheaf does not need to be a line bundle only coherent and flat over the base. We develop a little bit of a relative theory in section 3, so you might find the rest useful as well, especially the statement regarding a characterization via local cohomology. We did assume the codimension two condition for every fiber, but it might not be necessary actually. I would have to check the proof (I will try to do that sometime). I would add that (as you discovered) for a Hartogs type statement you do not need normality and many things can be done for $S_2$ schemes that are usually done for normal ones. The main reason normality is more widely used (besides that it is easier to define and think that one understands it better) is that working with divisors on $S_2$ but not normal schemes has to be done very carefully. See this MO answer for more on this and perhaps this and this for more on Hartogs type questions.
Best Answer
I think the property you want is that the canonical sheaf $\omega_X$ is S2. Note that on a normal affine variety, $\omega_X$ is not necessarily a line bundle (it is if $X$ is a complete intersection though).
For simplicity, let's assume $X \subseteq A^{n}$ is of dimension $d$. Then $$ \omega_X = Ext^{n-d}(O_X, O_{A^{n}}) $$ is a S2 sheaf. This implies that it satisfies Hartog's theorem. Not all sheaves do! For example, the ideal sheaf of a maximal ideal obviously does not (assuming $\dim X \geq 2$).
For a reference which discusses the S2 condition and relation to Hartog's phenomenon, see for example
Hartshorne, Generalized divisors on Gorenstein schemes.
I think Sándor Kovács has also written several good answers explaining this connection on mathoverflow.
A proof of the S2ness of $\omega_X$ for varieties can be found in Kollár-Mori, Birational geometry of algebraic varieties. Another proof can be found in Hartshorne's Generalized divisors and biliaison.