As Olivier's answer indicates, a direct approach to the computation using classical techniques of Sah and others is possible in a small isolated case like this. But it's a good idea to be aware of several different approaches to computations of finite group cohomology (or more generally, Ext functors). Most such computations are extremely hard to carry out explicitly, but sometimes it's enough to work in the setting of finite group cohomology with no added machinery. There are also some powerful techniques coming from algebraic topology (book of Adem-Milgram, etc.). For the groups $SL(2,p^n)$, a detailed study of the cohomology ring by Jon Carlson in Proc. LMS 47 (1983) shows how difficult the whole subject can be.
In the question here (and often in the study of Galois representations) you are dealing with a family of finite groups of Lie type, where it's often helpful to think about comparisons with the cohomology of the ambient algebraic group. Here there is an extensive literature, summarized concisely but with lots of references in my 2005 book Modular Representations of Finite Groups of Lie Type (LMS Lecture Note Series 326): work of Cline-Parshall-Scott and their collaborators, etc. In general the question asked has a transparent answer if the "top" or "bottom" layers of the projective cover of the trivial module can be worked out explicitly. This isn't at all easy in general, but for $SL(2,p^n)$ there is a fairly direct comparison with related modules for the algebraic group: see the paper by Henning Andersen et al. in Proc. LMS 46 (1983).
P.S. One advantage of looking directly at the projective cover of the trivial module (as in the last-cited paper) is that it explains why $p=5$ causes trouble: the two highest weights involved are $\lambda=0$ (trivial module) and $\mu =2$ (adjoint module), while the condition for existence of a nonsplit extension between them is easily seen from the algebraic group comparison to be $\lambda+\mu = p-3$.