Courts have "inherent authority to manage their dockets and courtrooms with a view toward the efficient and expedient resolution of cases." Dietz v. Bouldin, 136 S. Ct. 1885, 1892 (2016).
Courts routinely -- and relatively uncontroversially -- use this authority to do just the kinds of things you're talking about. Parties almost always have more witnesses and evidence available than the court is willing to entertain, so the courts frequently enter orders saying that the trial will be limited to X days, or that each side is limited to Y witnesses.
In addition to that inherent authority, courts are permitted to impose such restrictions under Federal Rule of Evidence 403, which permits the exclusion of evidence that is much more likely to waste time or be needlessly cumulative.
While the court has quite a bit of discretion in entering these orders, that authority is not unlimited. It may not be exercised to unfairly benefit one side or make it impossible to put on a case. Under Dietz, any exercise of this discretion must be a "reasonable response" to the challenges facing the court, and it must be tailored to avoid any unfair prejudice to the parties.
So if you're in small-claims court for missing a rent payment, it would generally be uncontroversial for the court to limit trial to one day, and limit the parties to two or three witnesses apiece. But if the court has a sprawling class-action involving multiple plaintiffs, multiple defendants, and multiple claims requiring expert testimony on scientific questions outside the understanding of the average juror, the court is going to be required to allocate quite a bit more time for trial.
I think it would be much less common, though, to have a judge say that the questions for Witness Z can only be one hour or something like that. Once the court has set an overall limit on how much time the sides have to present their case, they're not usually going to micromanage how that time is spent. Still, if a lawyer is really harping on a point that has already been made clear, it's quite normal for the judge to direct the lawyer to move on to other lines of questions.