I have the Stroke effect (made in Motion as Luis mentioned here) as a free download:
https://fcpxtemplates.com/sdm_downloads/stroke-effect/
You can animate from full screen to PiP by creating the animation (Scale All, Crop, and Position), then create a Compound Clip and apply Stroke to the Compound Clip.
The problem with using the Transform tools is that they are applied AFTER all other effects you add to a clip and that's why you can't use Crop at the "clip level" (requiring using the CC as mentioned) because it will also crop the border effect.
I have a "cheap 3rd party effect" that works on cropped PiPs here:
https://fcpxtemplates.com/sc-border-simple/
With this, you won't have to use a compound clip. You will be able to Crop, Scale and Position your clip with the border as well as Pan the clip within the border all within the effect.
In all honesty, if you have ANY other EFFECT that will position, scale and crop your clip, you can simply add the Stroke Effect after it and you will have a PiP with a border. You will be able to animate all those parameters and the border will stay with it all just as it would with the compound clip.