In my testing on OpenSSH 7.4, specifically:
$ ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
I was able to set my user's shell to either /sbin/nologin or /bin/false and was able to log into server B through server A.
Examples
$ cat /etc/passwd
user1:x:1001:1001::/home/user1:/sbin/nologin
or
$ cat /etc/passwd
user1:x:1001:1001::/home/user1:/bin/false
host A → B
Tries to log into server B (mulder) through server A (centos7) worked.
[vagrant@centos7 ~]$ ssh -J user1@localhost root@mulder
user1@localhost's password:
Last login: Sat Jul 21 15:59:00 2018 from macbook1
[root@mulder ~]#
host A → B → C
And on the off chance that it was something funny with my going through the VM, I added a 3rd host to the mix, and it still worked.
[vagrant@centos7 ~]$ ssh -J user1@localhost,user1@mulder root@skinner
user1@localhost's password:
user1@mulder's password:
Last login: Sat Jul 21 16:09:48 2018 from 192.168.1.10
[root@skinner ~]#
NOTE: in the above scenario, the user1 has /sbin/nologin defined in /etc/passwd on the servers centos7 & mulder.
Debugging your issue
So I'd start with -vvv switches to debug ssh.
$ ssh -vvv -J user1@localhost,user1@mulder root@skinner
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Setting implicit ProxyCommand from ProxyJump: ssh -l user1 -J user1@localhost -vvv -W %h:%p mulder
debug1: Executing proxy command: exec ssh -l user1 -J user1@localhost -vvv -W skinner:22 mulder
...
...
debug1: Setting implicit ProxyCommand from ProxyJump: ssh -l user1 -vvv -W %h:%p localhost
debug1: Executing proxy command: exec ssh -l user1 -vvv -W mulder:22 localhost
...
...
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last login: Sat Jul 21 16:10:28 2018 from 192.168.1.10
[root@skinner ~]#
NOTE: With the above you can see what -J is actually doing behind the scenes, as it expands to various ssh commands as it progresses through the jump proxy servers.
To triage your issue further, I'd suggest running these commands directly and seeing how they fare.
root@localhost → root@localhost
In my experiments I could ssh in the same manner that you were trying:
$ ssh -J root@localhost root@localhost
root@localhost's password:
root@localhost's password:
Last login: Sat Jul 21 16:40:54 2018 from localhost
CentOS 7 Build 1805.02
$
To do this you have to have /etc/ssh/sshd_config set so that root is permitted logging in.
References