Results are presented of a search for a heavy Majorana neutrino Nl decaying into two same-flavor leptons l (electrons or muons) and a quark-pair jet. A model is considered in which the Nl is an excited neutrino in a compositeness scenario. The analysis is performed using a sample of proton-proton collisions at sqrt(s)=13 TeV recorded by the CMS experiment at the CERN LHC, corresponding to an integrated luminosity of 138 fb−1. The data are found to be in agreement with the standard model prediction. For the process in which the Nl is produced in association with a lepton, followed by the decay of the Nl to a same-flavor lepton and a quark pair, an upper limit at 95% confidence level on the product of the cross section and branching fraction is obtained as a function of the Nl mass mNl and the compositeness scale Λ. For this model the data exclude the existence of Ne(Nμ) for mNl below 6.0 (6.1) TeV, at the limit where mNl is equal to Λ. For mNl ≈1 TeV, values of Λ less than 20 (23) TeV are excluded. These results represent a considerable improvement in sensitivity, covering a larger parameter space than previous searches in pp collisions at 13 TeV.