Going deeper with pseudo-polynomial time algorithm for set partitioning
You can extend the dynamic programming algorithm to handle this variant. Suppose that the weights are $w_1,\ldots,w_n$. You are looking for a vector $x \in \{0,\pm 1\}^n$ such that $\sum_{i=1}^n x_i w_i = 0$, and $\sum_{i=1}^n |x_i| w_i$ is as large as possible. This suggests two possible approaches. The first approach is to construct a large table keeping track of all possible pairs of values $(\sum_{i=1}^m x_i w_i, \sum_{i=1}^m |x_i| w_i)$, where $x_1,\ldots,x_m \in \{0,\pm 1\}^m$. This leads to an $O(nM^2)$ algorithm, compared to the $O(nM)$ subset-sum or partition algorithms.

The second approach is to explicitly list all vectors $x$ such that $\sum_{i=1}^n x_i w_i = 0$ (using dynamic programming), and choose the one maximizing $\sum_{i=1}^n |x_i| w_i$. This takes time $O(nM + nS)$, where $S$ is the number of vectors $x$ such that $\sum_{i=1}^n x_i w_i = 0$. In practice $S$ might be small enough for this approach to be practical.