Although the previous answers of @Jaap Scherphuis and my comment below need to compare colors, and hence colors need to be sorted, I tend to agree with @Retudin in the fact that colors are unlikely to be orderable (if just seen). Here is a way that I believe works without comparing colors that possesses probability of success of
I'm still not 100% sure that it works.
We can simply formalize the problem with a directed graph with $2^N$ vertices, where every vertices represents a possible combination of hats colors. Two nodes are connected with an edge if and only if the two corresponding combinations of hats differs by only one hat color. In this way for a prisoners observing the others hats mean to be on a edge connecting two different vertices and don't know in which direction to go. It is not difficult to see that every vertex is connected to $N$ different neighbors. Suppose that a prisoners see the vertices $v_j$ and $v_k$, meaning that depending on its hat color the arrangement of all hats is either $v_j$ either $v_k$, an arrow $v_j \rightarrow v_k$ is putted between the two connected vertices if this prisoner decide, in some way, that the color of his hat is such that the combination of all $N$ hat colors is the one corresponding to the vertex $v_k$. Let's make an example with $N=3$, the vertex $(0,0,0)$ is connected with an edge $(1,0,0)$. We put an arrow $(1,0,0) \rightarrow (0,0,0)$ and this mean that the first prisoner, that one observing $(0,0)$ decide to assume that his hat is also of color $0$ and so if whenever he will observe $(0,0)$ we will bet that their hat combination is $(0,0,0)$. It is clear from the fact that the prisoners don't know the colors that if a vertex correspond to a combination with only one color of type $0$ and $N-1$ colors of type $1$ (respectively only one hat of color type $1$ and $N-1$ colors of type $0$) then an arrow must exit from this node in the direction of the vertex with all colors of type $1$ (respectively pointing the vertex with all colors $0$). This constraint is the reason why with $N$ odd it is not possible, unlike the case $N$ even, to find a strategy that saves prisoners with certainty
Let fix some strategy $S$. We say that for a vertex $v_j$ the strategy $S$ is a winning strategy if all arrows point to its neighbors (meaning that each prisoner guess false) or if all arrows point to the vertex $v_j$ itself (meaning that each prisoner guess right). In other hands we say that for a vertex $v_j$ the strategy $S$ is a losing strategy if there is at least one arrow pointing the vertex $v_j$ and at least one arrow pointing one of its neighbors. We call winning set, the set containing all winning vertices.
It is clear that for $N$ odd cannot exist a winning strategy for every vertex. Assuming the contrary, if there exist a strategy $S$ for which every node is a winning strategy we necessarily have that all arrows connected to vertices $(0,0,\ldots,0) $ and $(1,1,\ldots,1)$ are pointing the vertices themselves, this is because the prisoners doesn't know the colors chosen by the warden. But we have that there exist a path of length $N$ (the number of edges) $(0,0,\ldots,0) $ to $(1,1,\ldots,1)$ an so we have found at least one losing vertex. Indeed we start with $$(0,0,0,\ldots,0,0) \leftarrow (1,0,0,\ldots,0,0) $$ and with $$ (1,1,1,\ldots,1,0) \rightarrow (1,1,1\ldots,1,1)$$ then we continue in this way $$(0,0,0,\ldots,0,0) \leftarrow (1,0,0,\ldots,0,0) \rightarrow (1,1,0,\ldots,0,0) $$ and $$ (1,1,\ldots, 1,0,0) \leftarrow (1,1,1,\ldots,1,0) \rightarrow (1,1,1\ldots,1,1)$$ we continue in this way and we notice that whichever way we put the $\left \lceil \frac{N}{2} \right \rceil$-th arrow we create a losing vertex. So it is impossible to have a strategy in which $N$ prisoners are saved with certainty.
It is simple to construct arrows in a such way that there are only $ \binom{N}{\left \lfloor N/2 \right \rfloor} $ losing vertices, and thus a strategy of success of $$ 1- \frac{\binom{N}{\left \lfloor N/2 \right \rfloor}}{2^N}. $$ For example with $N=3$ we start with $ (1,0,0) \rightarrow (0,0,0) \leftarrow (0,0,1) $ and $(0,0,0) \leftarrow (0,1,0) $. And $ (0,1,1) \rightarrow (1,1,1) \leftarrow (1,1,0) $ and $(1,1,1) \leftarrow (1,0,1) $ and from here we simply continue trying to maximize the winning vertex. So we see for example that if $(1,0,0)$ is a winning nodes then $ (1,1,0) \leftarrow (1,0,0)\rightarrow (1,0,1)$. From here we already deduce that $(1,1,0)$ and $(1,0,1)$ are losing vertices. The same for $(0,0,1)$.
and we get the following winning set $\{(0,0,0),(1,1,1), (1,0,0),(0,1,0),(0,0,1) \}$ and the following losing set $\{ (0,1,1),(1,0,1),(1,1,0) \}$
Now if the real combinations of hat is the vertex $v_r$ then every prisoners will observe $v_r$ together with another vertices different for each one. If $v_r$ is a winning vertices they simply follow the arrow and they will survive either by all guessing their own color or all guessing their own color wrongly. If $v_r$ is losing vertices they gonna die following the arrows. The question is the follow: what is the maximal cardinality of a winning set? Clearly if we found the set containing the winning vertices with maximal cardinality then we maximizes the probability of survival and as a optimal strategy the prisoners can simply build this winning set and then follow the arrows.
The answer of @Jaap Scherphuis needs the colors to be sortable in some way as well as my answer to his solution by adding the darker color, but at the same time these solution describes a way to create a winning set of cardinality $2^N - N$, hence as an optimal strategy they can simply choose in this way the arrows and the winning set and so we no longer need to compare colors since the very observation of colors and the assignment of arrow direction tells us which direction to go, and then which color to guess. They just need to agree on which color is $0$ and which color is $1$, and this I assume to be possible because otherwise how does the warden know whether they guessed their own color or not.