Using the example below, is there any way for Node1 or Node3 to be able to recognize that they are the final nodes on the CAN bus? I want to allow my device to automatically enable a 120Ohm termination in its circuit if it knows that it is the final node on the bus.
Not really. The bus won't work properly (at least not to spec) if it is not terminated. Likely there is no way in the CAN network to communicate to each node to organize how they would separately detect correct (or not) termination.
In principle, each node could (randomly ?) send signals on the bus, and watch for reflections. If there was only 1 reflection, it could presume it is on the end of the bus (and the reflection is from the far end); if there were 2 reflections (one from each end; these would be distinguishable only if it was not in the precise middle of the bus), then it could presume it is in the middle.
However ensuring that all nodes work independently (before communication is established) would not be possible over the (unterminated) CAN network.
Alternatively, a node could measure the effective impedance of the bus. All nodes not at the ends would see a transmission line impedance of Z/2, while the ones at the end would see Z. in practice this would be difficult because the (low cost) CAN transceivers couldn't measure this TDR (time-domain reflectometry) signal accurately enough. In addition, when there might be a cluster of nodes at the end of the bus, they couldn't easily distinguish which is the dominant one.
Do you have a CAN_IN and CAN_OUT connector on each device? Can you customize the connector? If so, maybe you could add a pair of pins to each connector. On the cable, the two pins would be shorted together. On the device, one pin would have a pullup and the other would be grounded. Any time a cable is plugged in, you can detect it because the loopback on the cable will force the pulled-up node to GND.
If a device has only one cable plugged in, it must be the last device, and should enable termination.
Can a node on a terminated end of a CAN bus self-identify that it is the final node?
Yes, if you have control over what connector you use to connect to the bus, and the design of the bus cable itself.
The cable that forms the backbone of the CAN bus will have connectors on it. If you are going to use one of the CAN nodes themselves to terminate the bus then that node must be on a specific connector that is physically at the end of the bus.
On all the bus connectors you can include GND, CAN_H, and CAN_L signals plus a fourth pin. On the nodes in the middle of the bus the 4th pin is blank. On the nodes at the end of the bus its not. On the end-nodes you can either jumper the 4th pin to ground to signal to the node that it should switch in termination. Or even easier, just jumper the 4th wire directly to the termination as shown below.