Probably not OK
See the Wikipedia article "Freedom of movement under United States law where it is mentioned that freedom to move from one state to another is a right protected under the Privileges and Immunities Clause of the US Constitution (Article IV, Section 2) This clause generally prevents states from treating citizens of other US states less favorably than local residents, although there are a good many exceptions
Specifically, the case of Crandall v. Nevada, 73 U.S. (6 Wall.) 35 (1868) the Court held that freedom of movement between states was a protected right under the Federal constitution. Specifically the Court held that that a state cannot discourage people from leaving a state by taxing them. In the opinion in that case, the Court wrote:
The people of these United States constitute one nation. They have a government in which all of them are deeply interested. This government has necessarily a capital established by law, where its principal operations are conducted. Here sits its legislature, composed of senators and representatives, from the states and from the people of the states. Here resides the President, directing through thousands of agents the execution of the laws over all this vast country. Here is the seat of the supreme judicial power of the nation, to which all its citizens have a right to resort to claim justice at its hands. Here are the great executive departments, administering the offices of the mails, of the public lands, of the collection and distribution of the public revenues, and of our foreign relations. These are all established and conducted under the admitted powers of the federal government. That government has a right to call to this point any or all of its citizens to aid in its service, as members of the Congress, of the courts, of the executive departments, and to fill all its other offices, and this right cannot be made to depend upon the pleasure of a state over whose territory they must pass to reach the point where these services must be rendered.
[T]he citizen also has correlative rights. He has the right to come to the seat of government to assert any claim he may have upon that government or to transact any business he may have with it. To seek its protection, to share its offices, to engage in administering its functions. He has a right to free access to its seaports, through which all the operations of foreign trade and commerce are conducted, to the subtreasuries, the land offices, the revenue offices, and the courts of justice in the several states, and this right is in its nature independent of the will of any state over whose soil he must pass in the exercise of it.
In the case of United States v. Wheeler, 254 U.S. 281 (1920) the court wrote:
In all the States from the beginning down to the adoption of the Articles of Confederation the citizens thereof possessed the fundamental right, inherent in citizens of all free governments, peacefully to dwell within the limits of their respective States, to move at will from place to place therein, and to have free ingress thereto and egress therefrom, with a consequent authority in the States to forbid and punish violations of this fundamental right.
but in that case the protection of this right was said to be in the hands of state authorities.
Edwards v. California, 314 U.S. 160 (1941) was a case about a law in California prohibiting bringing any "indigent person" into the state. The Supreme Court wrote:
Appellant is a citizen of the United States and a resident of California. In December, 1939, he left his home in Marysville, California, for Spur, Texas, with the intention of bringing back to Marysville his wife's brother, Frank Duncan, a citizen of the United States and a resident of Texas. ... [Duncan was unemployed after having worked for the WPA.] The two men agreed that appellant should transport Duncan from Texas to Marysville in appellant's automobile. ... When he left Texas, Duncan had about $20. It had all been spent by the time he reached Marysville. He lived with appellant for about ten days until he obtained financial assistance from the Farm Security Administration. ...
In Justice Court a complaint was filed against appellant under § 2615 of the Welfare and Institutions Code of California, which provides:
Every person, firm or corporation or officer or agent thereof that brings or assists in bringing into the State any indigent person who is not a resident of the State, knowing him to be an indigent person, is guilty of a misdemeanor.
... appellant was convicted and sentenced to six months imprisonment in the county jail, and sentence was suspended. ...
Article I, 8 of the Constitution delegates to the Congress the authority to regulate interstate commerce. And it is settled beyond question that the transportation of persons is "commerce" within the meaning of that provision. . California v. Thompson, 313 U. S. 109, 313 U. S. 113. The issue presented in this case, therefore, is whether the prohibition embodied in § 2615 against the "bringing" or transportation of indigent persons into California is within the police power of that State. We think that it is not, and hold that it is an unconstitutional barrier to interstate commerce.
But this does not mean that there are no boundaries to the permissible area of State legislative activity. There are. And none is more certain than the prohibition against attempts on the part of any single State to isolate itself from difficulties common to all of them by restraining the transportation of persons and property across its borders. ... [I]n the words of Mr. Justice Cardozo:
The Constitution was framed under the dominion of a political philosophy less parochial in range. It was framed upon the theory that the peoples of the several States must sink or swim together, and that, in the long run, prosperity and salvation are in union, and not division."
It is difficult to conceive of a statute more squarely in conflict with this theory than the Section challenged here. Its express purpose and inevitable effect is to prohibit the transportation of indigent persons across the California border. The burden upon interstate commerce is intended and immediate; it is the plain and sole function of the statute. ...
It is urged, however, that the concept which underlies § 2615 enjoys a firm basis in English and American history. [Footnote 2] This is the notion that each community should care for its own indigent ... We do, however, suggest that the theory of the Elizabethan poor laws no longer fits the facts. Recent years, and particularly the past decade, have been marked by a growing recognition that, in an industrial society, the task of providing assistance to the needy has ceased to be local in character.
This Court has repeatedly declared that the grant [the commerce clause] established the immunity of interstate commerce from the control of the States respecting all those subjects embraced within the grant which are of such a nature as to demand that, if regulated at all, their regulation must be prescribed by a single authority. Milk Control Board v. Eisenberg Farm Products, 306 U. S. 346, 306 U. S. 351.
We are of the opinion that the transportation of indigent persons from State to State clearly falls within this class of subjects. The scope of Congressional power to deal with this problem we are not now called upon to decide.
The right to travel was later reiterates in United States v. Guest, 383 U.S. 745 (1966). In the opnion in that case, the court wrote:
The constitutional right to travel from one State to another, and necessarily to use the highways and other instrumentalities of interstate commerce in doing so, occupies a position fundamental to the concept of our Federal Union. It is a right that has been firmly established and repeatedly recognized. In Crandall v. Nevada
In Edwards v. California, 314 U. S. 160, invalidating a California law which impeded the free interstate passage of the indigent, the Court based its reaffirmation of the federal right of interstate travel upon the Commerce Clause. This ground of decision was consistent with precedents firmly establishing that the federal commerce power surely encompasses the movement in interstate commerce of persons as well as commodities. See also Gloucester Ferry Co. v. Pennsylvania, 114 U. S. 196; Covington & Cincinnati Bridge Co. v. Kentucky, 154 U. S. 204, 154 U. S. 218-219; Hoke v. United States, 227 U. S. 308, 227 U. S. 320; United States v. Hill, 248 U. S. 420, 248 U. S. 423.
In short,. in addition to the Pennsylvania law cited in another answer, a flat ban on persons from another state driving in any particular state might well violate protected constitutional rights, although a state is not required to honor another state's driving license, even though all states now do so. Much would depend on exactly how such a regulation or law was worded. If it purported to ban all travel from another state, it would probably fail.
This is not to say that a state may not insist on proper driving licenses. It may, and it is not required to accept licenses from other states. Nor is this to claim that all traffic regulations are preempted by the Commerce Clause. As the Court said in the Edwards case quoted above:
It is nevertheless true, that the States are not wholly precluded from exercising their police power in matters of local concern even though they may thereby affect interstate commerce
Temporary restrictions based on health and safety issues, such as pandemic quarantine orders, would probably pass review. But a flat ban such as the one jokingly suggested in the question, without regard for exposure or tiem in a state, probably would not, and as far as I know, no state has attempted such a ban in response to the current pandemic.