Yes, you can.
First though, you say image A is on a server that has no internet connection. If that is true, then you can't access the built image B that you've pushed to x.x.x.x unless the x.x.x.x that you refer to is localhost.
To answer the question fully with the assumption that there's no internet:
Dockerfile B contains all the stuff you want in your base image. Build that. Then move the image to the internet-less server that you're building image A on. (To move the image, check out docker export or docker save commands and/or google 'moving a docker image from one host to another'. My initial search lead me here: https://blog.giantswarm.io/moving-docker-container-images-around/)
(note: for anyone that wants to do this and you have a internet connection, you would push image B to a repo and then pull the image straight from there in Dockerfile A which would skip the moving from host to host part.)
Then, just like you've written already, the Dockerfile for image A should have:
FROM imageB:latest
to pull from your first image. It's all pretty easy. Long story long, yes, you can build your own images and then build other images based off of that image.
$ docker run -d -p 5000:5000 --restart=always --name registry registry:2