I’d say it depends on the company you’re applying to, and your confidence in your own level of prep.
For instance, if it’s a big company, I think they’re used to people scheduling interviews even 3-4 weeks in advance to get ample time to prep for the interview. But if you’ve already been targeting a company and have been prepping for it, then scheduling it sooner would be fine as well. In short, bigger companies imo are more flexible and have the resources to allow for longer wait periods.
For smaller to medium size companies, I usually keep it within a week or two, since they are looking to fill positions fast, and how early you give the interview might factor into how big of a candidate pool you are assessed in, the earlier the fewer people, the better your chances (not always, but I think it’s likely). But it also depends on the prep you’ve already put in. If you feel comfortable and prepared, and it fits your schedule, I’d lean towards interviewing sooner than later for these companies.
All the best!