The United States government controls who receive military benefits. This is even true in a divorce.
Regardless of what you ask or what you or your former spouse want, the court will have to follow government guidelines when allowing you to keep your benefits or take them away from you. The basic rule that would allow you to keep your military ID and associated benefits are the 20/20/20 rule.
This rule says if your marriage lasted at least 20 years and 20 of those years your spouse was in the service and your spouse was in for at least 20 years, then you can keep your privileges. You receive full benefits under this rule as if you were continuing the marriage.
If you are almost to the point of meeting the 20/20/20 rule but fall short, you may be able to get partial privileges based on the 20/20/15 rule. Under this rule, your marriage must be for 20 years, service of your spouse must be 20 years, but only 15 of those years must overlap.
Another exception is if your spouse had a domestic violence conviction and lose his or her eligibility for retired pay. You could then get partial entitlement.
If you remarry, you lose all military benefits associated with your former spouse. You must turn your ID back into the military if this happens.
The 20/20/20 rule is a standard. The court cannot overrule it or make changes to it. The rule comes from the government and only it can make changes.