If a US State passed a law regarding the eligibility of Presidents,
could it be enforced?
"Suppose (the citizens of) a state were tired of government shutdowns
and they or their legislature passed a law prohibiting members of
Congress and Presidents involved in a governmental shutdown from being
elected again." . . .
Could a State deny a candidate a spot on the ballot [for this reason]?
Could a State deny its electors to such a presidential candidate even
if they won a write-in campaign?
The leading case on point is U.S. Term Limits, Inc. v. Thornton, 514 U.S. 779 (1995), which holds that qualifications to running as a candidate for federal office not found in the U.S. Constitution may not be imposed by state law. This expanded upon a 1969 holding of the U.S. Supreme Court which it noted in the beginning of its ruling:
Today's cases present a challenge to an amendment to the Arkansas
State Constitution that prohibits the name of an otherwise eligible
candidate for Congress from appearing on the general election ballot
if that candidate has already served three terms in the House of
Representatives or two terms in the Senate. The Arkansas Supreme Court
held that the amendment violates the Federal Constitution. We agree
with that holding. Such a state imposed restriction is contrary to the
"fundamental principle of our representative democracy," embodied in
the Constitution, that "the people should choose whom they please to
govern them." Powell v. McCormack, 395 U.S. 486, 547 (1969)
(internal quotation marks omitted). Allowing individual States to
adopt their own qualifications for congressional service would be
inconsistent with the Framers' vision of a uniform National
Legislature representing the people of the United States. If the
qualifications set forth in the text of the Constitution are to be
changed, that text must be amended. . . .
As the opinions of the Arkansas Supreme Court suggest, the
constitutionality of Amendment 73 depends critically on the resolution
of two distinct issues. The first is whether the Constitution forbids
States from adding to or altering the qualifications specifically
enumerated in the Constitution. The second is, if the Constitution
does so forbid, whether the fact that Amendment 73 is formulated as a
ballot access restriction rather than as an outright disqualification
is of constitutional significance. Our resolution of these issues
draws upon our prior resolution of a related but distinct issue:
whether Congress has the power to add to or alter the qualifications
of its Members.
Twenty six years ago, in Powell v. McCormack, 395 U.S. 486 (1969), we
reviewed the history and text of the Qualifications Clauses in a case
involving an attempted exclusion of a duly elected Member of Congress.
The principal issue was whether the power granted to each House in
Art. I, §5, to judge the "Qualifications of its own Members" includes
the power to impose qualifications other than those set forth in the
text of the Constitution. In an opinion by Chief Justice Warren for eight Members of the Court, we held that it does not.
The Court went on to hold that:
The provisions at issue in Storer and our other Elections Clause cases
were thus constitutional because they regulated election procedures
and did not even arguably impose any substantive qualification
rendering a class of potential candidates ineligible for ballot
position. They served the state interest in protecting the integrity
and regularity of the election process, an interest independent of any
attempt to evade the constitutional prohibition against the imposition
of additional qualifications for service in Congress. And they did not
involve measures that exclude candidates from the ballot without
reference to the candidates' support in the electoral process. Our
cases upholding state regulations of election procedures thus provide
little support for the contention that a state imposed ballot access
restriction is constitutional when it is undertaken for the twin goals
of disadvantaging a particular class of candidates and evading the
dictates of the Qualifications Clauses.
There is a gray area concerning what constitutes a qualification as opposed to a procedural election administration requirement (which may constitutionally be used to limit ballot access), but the standard described in the question would clearly be treated as a qualification and disallowed as an unconstitutional limitation.
In contrast, states can, for example, impose petition requirements or require payment of filing fees, in order for candidates to secure ballot access, in a way that is unrelated to a qualifications of the candidate not set forth in the U.S. Constitution.
See also Colorado Department of State v. Baca, 591 U.S. ___ (2020) which was consolidated with Chiafalo v. Washington, 591 U.S. ___ (2020), in which the U.S. Supreme Court ruled unanimously that states have the ability to enforce an elector's pledge in presidential elections.
There is no meaningful constitutional difference between this case prohibiting this practice for members of Congress, and a law that would impose similar limitations on electors pledged to particular Presidential candidates on the same basis.