You can do that several ways. Here is one way using tunneling. First set up a tunnel:
$ ssh -L 2222:machine2.example.org:22 machine3.example.org
Next connecting to the tunnel will actually connect to the second host, machine2.
$ ssh -p 2222 remoteuser@localhost
Another way is to use ProxyCommand in the configuration, either in the ~/.ssh/config file or in the runtime arguments.
$ ssh -o 'ProxyCommand ssh %h nc machine2.example.org 22' -o 'HostKeyAlias machine2.example.org' machine3.example.org