Sure you can. I do it frequently. I record any call coming from an "unknown" CallerID and from numbers not in my contacts list.
What phone? I've tried:
-Moto G Stylus 2023
-Moto G Stylus 5G
-Pixel 4a (Graphene OS)
-LG V20
^never worked, IIRC
-LG V10
-LG Stylo 2
-LG Stylo
^Once worked, IIRC
Depends on the device maker and how close to stock they keep things. Some include the stock AOSP Phone app, others use their own special modified version and few use something completely different.
I believe the Play Services 'service' is also involved.
I can remember resetting the Stylo 2 to factory, installing the recorder app, it worked; and then google play/services updated, and it broke.
Perhaps minimalized or stripped-out Gapps works? Or, maybe it really is entirely up to the phone/firmware/OS, and I've had especially bad luck.
(It didn't help that the person I was trying to get this working for, forgot how to operate their own multi-year-owned phone, regularly, either...)
It's a pretty serious sore spot for me, that this feature became actively blocked.
Primary legitimate use for such, was for those with disabilities.
Now, go actually try to use it, in a call. My experience has been that those will only record one-side of a call.
edit:
Now that I'm thinking about it...
It's not impossible that I live(d) in a state that explicitly has made phone recording (w/o permission) illegal, and may have forced Google to enforce it.