Determinant of an "almost cyclic" matrix Let $n\geq 3$, let $Z$ be the matrix of the cyclic shift (the companion matrix of $X^n-1$), and for $\mathbf{d}\in \mathbb{C}^n$ let
$\operatorname{diag}(\mathbf{d})$ be  the diagonal matrix with $\mathbf{d}$ on the diagonal,
and $$M_\mathbf{d}:=\operatorname{diag}(\mathbf{d})+Z+Z^2$$.
Notation: call a subset of $[n]:=\{1,\ldots,n\}$ separated if does not contain  two (cyclically) adjacent elements, let $S_j(n):=\{ M\in [n]\;:\, |M|=j\}$ denote the set of separated subsets of $[n]$ with $j$ elements.
For $n\leq 12$  the determinant is given by:
$$\det(M_{\mathbf{d}})=\sigma_n(d) +\sum_{j=0}^{n-1}  (-1)^{n-j-1} \sigma_j(\mathbf{d})$$
where
$\sigma_0(\mathbf{d})=\det(Z+Z^2)=\bigg\{\begin{array}{cr} 
  2 & \text{ for odd } n\\
        0 & \text{ for even } n\end{array}$
$\sigma_1(\mathbf{v})=d_1+\ldots+d_n$,  $\sigma_n(\mathbf{v})=\prod_{i=1} d_i$, 
and for $2\leq j \leq n$
$$\sigma_j(\mathbf{v})= \sum_{(k_1,\ldots,k_j)\in S_j(n)}\prod_{i=1}^j d_{k_i}$$
Does the formula hold for all $n\geq 3$? 
Motivation: this (and related) determinants appear in a combinatorial problem arising in homological algebra, see Classification of algebras of finite global dimension via determinants of certain 0-1-matrices
 A: For a length $n-1$ vector $a=(a_1,\dots,a_{n-1})$, define the $n$-by-$n$ tridiagonal matrix $T(a)$ with $1$'s on its main diagonal and subdiagonal and $a$ on its superdiagonal. The first two determinants are $\det T(\emptyset)=1$ and $\det T(a_1)=1-a_1$. By cofactor expansion on the last row we have $\det T(a_1,\dots,a_{n-1})=\det T(a_1,\dots,a_{n-2})-a_{n-1}\det T(a_1,\dots,a_{n-3})$.
Define $\tilde S_j(n)$ in a similar way but with linear (not cyclic) adjacency. Define also $\tilde \sigma_j(a)=\sum_{(k_1,\ldots,k_j)\in \tilde S_j(n-1)}\prod_{i=1}^j a_{k_i}$ for $0\le j\le n-1$. It's not hard to prove that $\det T(a_1,\dots,a_{n-1})=\sum_{j=0}^{n-1} (-1)^j\tilde\sigma_j(a)$ by showing both sides have the same initial conditions and satisfy the same recurrence.
I'll take $Z_{ij}=\delta_{i,j+1}$ (subscripts taken cyclically). $M$ is a lower triangular matrix $L$ plus three $1$'s in the upper right corner at $(1,n-1)$, $(1,n)$, and $(2,n)$.
The terms in the expansion of $\det M$ which do not contain any of these $1$'s contribute $\det(L)=\sigma_n(d)$.
The terms which contain exactly one of the three $1$'s contribute $(-1)^{n-1}\det T(d_2,\dots,d_{n-1})$, $(-1)^nd_n\det T(d_2,\dots,d_{n-2})$, and $(-1)^nd_1\det T(d_3,\dots,d_{n-1})$ from the minors at $(1,n)$, $(1,n-1)$, and $(2,n)$ respectively.
The final terms contain the $1$'s at $(1,n-1)$ and $(2,n)$ and contribute $1$ to the determinant, since the minor is upper triangular with $1$'s on its diagonal.
It's straightforward to show that these five terms add up to your formula.
