TL;DR: No, rovers do not remain in constant contact with the Earth since it is impractical to do so, and it's unlikely that any mission will attempt to do so in the future.
Generally, there are a few constraints on communication that make it difficult and impractical to be in constant communication with the Earth, the main ones being line-of-sight, power, and cost.
1. Line-of-sight
As you allude to in your post, perhaps the number one obstacle to constant (i.e. non-stop) communication between a rover (on any planetary body, not just Mars) and the Earth is whether or not there is line-of-sight. Since the electromagnetic waves used to communicate between the rover and the Earth-based ground station travel in straight lines through vacuum (see https://physics.stackexchange.com/questions/93243/do-electromagnetic-waves-always-move-in-straight-lines for a discussion on what happens when EM waves encounter an atmosphere), we lose contact with the rover during planetary nighttime (i.e. when the planetary body the rover is located on rotates away from the Earth). The exception is when a celestial body, such as the Moon, is tidally-locked with the Earth, since this would mean that the same side of the celestial body always faces Earth. Since Mars is not tidally locked with the Earth, we thus can expect there to be periodic signal outages. A way of getting around this is to use a relay satellite, but since Perseverance is using direct-to-Earth communication, I won't go into that here.
2. Power
"This is all fine," you're probably thinking, "but doesn't answer my question." What about when we do have line of sight? A major constraint for us in terms is communication is electrical power. As with most rovers, power is a fairly precious commodity; given the amount of scientific instrumentation and auxiliary hardware that needs to be packed into the rover, there's a fine balance to be struck in terms of the total amount of power that can be generated and the mass of the equipment required to produce that power (an increase in which either necessitates extra fuel/a larger footprint/a larger parachute/etc., or a reduction in the amount of instrumentation that's included on the rover). Since we want to spend most of our mission time collecting data and exploring cool new worlds (since that's the entire point of our being on Mars!) we don't want to spend too much of our power on the power-heavy task of transmitting data. Thus, if we are to avoid draining our battery faster than we can charge it, we need to carefully plan when we want to do certain tasks - when we want to collect samples, when we want to process them, when we want to beam our results back to Earth, etc. - and that involves putting time limits on those activities. Thus, it doesn't make sense (from a mission perspective) to remain in constant communication with the Earth (and to keep all the communication fully powered all the time). The information on how long the rover spends on each task in its concept of operations, and how much power each activity consumes, is typically contained in a power timeline (which evolves throughout the mission depending on the rover's health and mission priorities). You can typically find overviews of these plans in journal articles describing the mission concept of operations (ConOps). The following paper is a really great read if you want to know more about Perseverance:
Mustard, J. F., Adler, M., Allwood, A., Bass, D. S., Beaty, D. W.,
Bell, J. F., ... & Edgett, K. S. (2013). Report of the Mars 2020
science definition team. Mars Explor. Progr. Anal. Gr, 150, 155-205.
3. Cost
Money makes the world go 'round, and even for big space agencies like NASA, ESA, JAXA, etc., cost is an important factor in determining what activities are part of a mission's ConOps (and how long those activities last). The Perseverance rover uses direct-to-Earth (DTE) communication (see the Mustard et. al. article), which means that it'll communicate with Earth using the Deep Space Network (DSN). The DSN is shared by several different NASA missions, as well as by other external partners, and time on the DSN is quite costly. (This StackExchange post includes an in-depth discussion of the DSN, inclusive of examples of just how short communication links generally are on the DSN.) An earlier StackExchange post also went over just how much time on the DSN costs; for a mission that's already going to have a sizable amount of its finances tied up in assembling the rover, a paying a team to design/build/monitor it over a period of several years, and getting a rocket to take the rover to its destination, paying to use the DSN whenever the rover's in line-of-sight doesn't make financial sense. Instead, it's preferable to manage your data budget to make sure that there's no need for you to be in constant contact with the Earth, and to compress your data as much as possible so that you can transmit your data efficiently.
Conclusion
There are a few other factors that place a limit on the uptime for a DTE communication link, but these are the major ones.