Assuming that the context the template is called in is a child-node selection then I offer the below. If the context they were called in was via a different axis (say preceding-sibling or ancestor) then the way to approach it is best.
Two possibilities are to simplify the tests, or to replace them with different templates:
Simpler tests:
<xsl:template match="sect1">
<xsl:if test="position() = 1">
<!-- Special handling for first sect1 element goes here. -->
</xsl:if>
<!-- Common handling for all sect1 elements goes here. -->
<xsl:if test="position() = last()">
<!-- Special handling for last sect1 element goes here. -->
</xsl:if>
</xsl:template>
Different templates:
<xsl:template name="handleSect1">
<!-- Common handling for all sect1 elements goes here. -->
<xsl:template>
<xsl:template match="sect1">
<xsl:call-template name="handleSect1"/>
</xsl:template>
<xsl:template match="sect1[1]">
<!-- Special handling for first sect1 element goes here. -->
<xsl:call-template name="handleSect1"/>
</xsl:template>
<xsl:template match="sect1[last()]">
<xsl:call-template name="handleSect1"/>
<!-- Special handling for last sect1 element goes here. -->
</xsl:template>
<xsl:template match="sect1[position() = 1 and position() = last()]">
<!-- Special handling for first sect1 element goes here. -->
<xsl:call-template name="handleSect1"/>
<!-- Special handling for last sect1 element goes here. -->
</xsl:template>
Since you say "optimise" I assume you care about which will process faster. It will vary according to xslt processor, processing modes (some have a "compile" option, and this will affect which is more efficient) and input XML. The fastest may be either of these or your original.
Really, every one of these should be as efficient as the other, the difference is in optimisations that the processor manages to make.
I would favour the first in my answer here in this case, as it's the most concise, but if I was to not have common handling shared between all 4 cases, I would favour the approach in the second answer, which then clearly marks different approaches for each case.