The short answer is yes, if you have called traffic in sight then ATC has an expectation that you will be able to maintain sight and provide your own separation. You need to notify them if you are no longer able to do so so that they can resume providing separation service.
However, you are not expected lock eyeballs on the target and maintain sight 100% of the time. You also need to continue to scan your instruments and keep a good lookout for other traffic. It is understandable that you might lose sight periodically before you see them again. The time spent trying to re-acquire before you confess on the radio depends on the situation, and this is why situational awareness is so important. What you actually say, (other than a simple "lost sight") may also depend on the situation.
Let me offer a couple examples:
SCENARIO 1: In the example you provided, both aircraft are of the same type and are presumably both on approach to the same runway. 2 miles is a full minute of separation at 120 knots, so as long as they are not excessively slow and you are not excessively fast you should be able to maintain plenty of spacing. Keeping sight of a tail-on aspect, lost in the ground clutter with no track crossing angle to cause your eye to catch the motion, can be very challenging. Unless tower directs the first aircraft to perform a 360 for spacing there is no reason to anticipate a conflict. You still need to ‘fess up on the radio, but rather than compromising the rest of your scan by implying that you will keep looking hard for this one airplane, I might attempt to shed responsibility by saying something like “Tower, N123 unable to maintain sight of traffic, let me know if it becomes a factor” and carry on with my approach. They are generally understanding, and if it isn't urgent you will likely hear a friendly "Roger, traffic is on short final now, no factor."
SCENARIO 2: On the other hand, let’s say you are on that same straight in approach, maybe dragging in a little bit low in a high wing 172, and tower calls #1 traffic as a Piper on downwind. You initially see the traffic on downwind, but subsequently lose sight. When that low wing Piper starts their base turn, (and turn to final) they will likely lose sight of you behind the wing, and if you don’t have them in sight the safety risk is far, far greater than in the first scenario. In the second case the hair on the back of your neck should go up, and you need to speak up early and often until you are assured that there will be no conflict. I have been criticized for offering examples of radio communications that aren’t strictly by the book, but in any non-standard situation the most important thing is to get your point across. And be directive if you need something. Examples of what I might say include: “Tower, N123 lost sight, say position of Piper”. “Tower, N123, is the Piper on base leg yet? I've lost contact.” “Tower, N123, call my traffic please.” "Tower N123, where's my interval?!".
Be assertive, speak clearly, but most importantly don’t hit another airplane worrying whether you should speak up or fumbling over proper phraseology when simple plain language will inform ATC of your situation and let them give you the help you need.