Does a layer2 switch forms a ARP table ?
first of all, we need to distinguish between CAM table and ARP table they are two different concepts
a L2 switch uses the CAM table to forward frames within the same broadcast domain, typically from an host to its default gateway of between two hosts in the same subnet.
In this a L2 switch acts as a transparent bridge that learns MAC addresses by listening to frames received on its ports.
And also means the L2 switch cannot change a frame (transparent) it just decides if the frame has to be forwarded or discarded.
The CAM table uses vlan number, port, MAC address to organize information
A L2 switch has also an ARP table that is used by the switch management TCP/IP stack in order to be managed by remote: to support SNMP, telnet, SSH, ICMP and so on.
An ARP table is a list of associations IP address / MAC address, multiple IP addresses can be associated to the same MAC address
Jon and Ganeshh have explained the scenario that you have proposed.
I've just written two notes about terminology.
As Jon has noted only the router can perform packet rewrite that means changing the ethernet frame header (MAC SA, MAC DA) and also IP packet header (reduce TTL and recalculate checksum).
A transparent bridge = L2 switch can only decide between forwarding or not forwarding a frame ( L2 PDU)
A frame is not forwarded if according to switch CAM table frame destination MAC address is on the same port where the frame has been received.
Hope to help