Could the US Congress enact legislation to prevent specific individuals from being elected to federal government offices?
In addition to the Constitutional qualifications, one may become ineligible to federal office by being impeached by the House, convicted and removed from office by the Senate, and having the Senate add the "disqualification" term to the sentence. This is surely something done by the legislature but it is not done by passing a law.
One may also become ineligible by being convicted of treason or insurrection, and possibly other relevant federal offenses.
Specifically 18 U.S. Code § 2381 provides that:
Whoever, owing allegiance to the United States, levies war against them or adheres to their enemies, giving them aid and comfort within the United States or elsewhere, is guilty of treason and shall suffer death, or shall be imprisoned not less than five years and fined under this title but not less than $10,000; and shall be incapable of holding any office under the United States. (emphasis added)
18 USC §2383 provides that:
Whoever incites, sets on foot, assists, or engages in any rebellion or insurrection against the authority of the United States or the laws thereof, or gives aid or comfort thereto, shall be fined under this title or imprisoned not more than ten years, or both; and shall be incapable of holding any office under the United States. (emphasis added)
Whoever, with intent to cause the overthrow or destruction of any such government, prints, publishes, edits, issues, circulates, sells, distributes, or publicly displays any written or printed matter advocating, advising, or teaching the duty, necessity, desirability, or propriety of overthrowing or destroying any government in the United States by force or violence, or attempts to do so; or
Whoever organizes or helps or attempts to organize any society, group, or assembly of persons who teach, advocate, or encourage the overthrow or destruction of any such government by force or violence; or becomes or is a member of, or affiliates with, any such society, group, or assembly of persons, knowing the purposes thereof—
Shall be fined under this title or imprisoned not more than twenty years, or both, and shall be ineligible for employment by the United States or any department or agency thereof, for the five years next following his conviction.
If two or more persons conspire to commit any offense named in this section, each shall be fined under this title or imprisoned not more than twenty years, or both, and shall be ineligible for employment by the United States or any department or agency thereof, for the five years next following his conviction. (emphasis added)
18 USC §2387 provides in relevant part that:
(a) Whoever, with intent to interfere with, impair, or influence the loyalty, morale, or discipline of the military or naval forces of the United States:
(a) (1) advises, counsels, urges, or in any manner causes or attempts to cause insubordination, disloyalty, mutiny, or refusal of duty by any member of the military or naval forces of the United States; or
(a) (2) distributes or attempts to distribute any written or printed matter which advises, counsels, or urges insubordination, disloyalty, mutiny, or refusal of duty by any member of the military or naval forces of the United States—
Shall be fined under this title or imprisoned not more than ten years, or both, and shall be ineligible for employment by the United States or any department or agency thereof, for the five years next following his conviction. (emphasis added)
(See also Chapter 115 which collects these and related sections of title 18.)
(See also the Wikipedia article)
(See further "A Civilian's Guide to Insurrection Legalese" from The Marshall Project.)
In United States v. Burr, 8 U.S. (4 Cranch) 470 (1807) Chief Justice Marshall wrote an opinion overturning the conviction of Aaron Burr, because Burr was not actually present at the overt act proved, as charged in the indictment.
In Cramer v. United States, 325 U.S. 1 (1945) a conviction for treason was overturend because the court held the "overt acts ... as proved were insufficient to support a finding that the accused had given aid and comfort to the enemy"
Possible Future laws
While treason is defined (or more exactly limited) by the constitution (Article III section 3), nothing in the constitutional provision requires or specifically authorizes that the penalty include ineligibility to office. (It merely says "The Congress shall have power to declare the punishment of treason".) There is no specific Constitutional authorization for 18 USC 2383, 2385, or 2387, or their penalty sections beyond the general authority of Congress to pass laws and define crimes and their penalties.
I am not certain that "employment" in 2385 and 2387 includes elective office, but I suspect it does. 2383 clearly includes elective office. Thus Congress has passed laws, with no specific constitution authorization, that deny people, as punishment for relevant crimes, eligibility to office or employment under the United States. What Congress has done in one case, it could do in another, if it saw fit.
Congress could pass a law creating a new offense, or modifying an existing offense, to add the penalty of disqualification. But the Constitutional prohibition of ex post facto laws would mean that such a law would not apply to conduct that occurred before the law was passed or amended.
Congress may not declare a person guilty of a particular crime; that would be a bill of attainder, which is also specifically prohibited in the Constitution. A criminal conviction by a court is required to trigger the ineligibility provisions of sections 2381, 2383, 2385, 2387, or any similar law.
Section 3 of the 14th Amendment to the US Constitution reads:
No Person shall be a Senator or Representative in Congress, or elector of President and Vice-President, or hold any office, civil or military, under the United States, or under any State, who, having previously taken an oath, as a member of Congress, or as an officer of the United States, or as a member of any State legislature, or as an executive or judicial officer of any State, to support the Constitution of the United States, shall have engaged in insurrection or rebellion against the same, or given aid or comfort to the enemies thereof. But Congress may by a vote of two-thirds of each House, remove such disability.
This forms another ground whereby an individual can be barred from some federal and state offices, but it is not one that can be invoked by Congress for specific people by name. Indeed it is not clear how it can currently be invoked. This provision requires a judicial determination that it applies to a specific person. From 1868 to 1872 there was a law in force for this purpose, but in 1872 Congress granted a broad amnesty which exempted most of those who would otherwise have been subject to this provision because of the US Civil War, and the law was soon repealed. In the wake of the events of 6 Jan 2021 several bills have been introduced to create ma new enforcement mechanism for this provision. To the best of my knowledge, none have yet been passed into law. See "The 14th Amendment’s Disqualification Provision and the Events of Jan. 6" for so9em relevant details and background. That article also says:
Section 3 is different from a disqualification from federal office imposed as a sentence for an impeachment conviction. A disqualification sentence from the Senate is final and not, for all intents and purposes, subject to judicial review.
By contrast, Congress cannot simply declare an official outside of that body ineligible under Section 3 without the concurrence of the courts. To hold otherwise would allow simple majorities in Congress to oust federal and state officials without judicial scrutiny ...
The President, Vice-President, Senators and Congressmen are the only elected federal officials, and their qualifications are described in the US Constitution (Art 1, Sect 2, Clause 1 & 2 for Representatives, Art 1, Sect 3, Clause 3 for Senators; Art. 2, Sect 1, Clause 5 for President). Congress cannot impose any other qualifications, see Powell v. McCormack, 395 U.S. 486. Nor may states impose additional qualifications, see U.S. Term Limits, Inc. v. Thornton, 514 U.S. 779; Cook v. Gralike, 531 U.S. 510.